Ubuntu – Why I can’t access internet using an static IP address


I want to set up my machine with a static IP address. I've done it before and it worked.

It's been a long time so, once again, I researched how to do it before starting. It looked pretty familiar and I could remember the process from before … so I got started …

I should mention that this is a new installation. The only thing I did before attempting this was to do an update and install ssh.

The first thing that I thought was odd was the contents of /etc/network/interfaces. It looked like this:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

Where's the stuff I usually find (and the walk through pages all seemed indicate that I would find) for eth0? I was expecting to see:

auto eth0
iface eth0 inet dhcp

Funny thing is, it did pick up an IP address – – which is a bit odd because IPs are usually assigned on a sequential basis and I would have expected it to pick up because this was the next available IP.

Anyway, all this oddness aside, I ploughed on. I added the following to /etc/network/interfaces

auto eth0
iface eth0 inet static

Then the next dose of oddness … I issued the following command: /etc/init.d/networking restart … nothing happened. No error messages, nothing at all. So, I tried this: service networking restart … this is what happened:

stop: Job failed while stopping
start: Job is already running: networking

So I rebooted. The network configuration looked just great. I could ssh into the machine from inside my internal network. At this moment I thought I'd done it and I could forget the odd stuff. But no, the next thing I did was run apt-get update … it failed … I tried to ping a couple of websites and nothing would resolve so I'm guessing it's not finding a DNS server.

But it's just a guess and it doesn't help me because I don't know what to try next.

Best Answer

  • The default /etc/network/interfaces file only contains the loopback interface definition because desktop versions of Ubuntu use the NetworkManager service instead.

    Your current configuration is missing a dns-nameservers specification, so it cannot resolve names to IP addresses.

    You could add one or more dns-nameservers, however unless you have a particular reason to use the networking service, it would probably be better to revert your changes and then set up a static interface via NetworkManager's nm-applet (from the menu bar) or by invoking nm-connection-editor from a terminal - navigate to the IPV4 Settings tab and change the drop-down Method: from DHCP to Manual and then enter your desired network parameters there.