Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up a static local IP address for my Linux computer for port-forwarding purposes. As per every single guide that exists on this subject, I've edited my /etc/network/interfaces and /etc/resolv.conf files accordingly. However, upon rebooting, any changes I've made to resolv.conf are erased and the file is blank (except for the comment that warns me of exactly that).

As a result, I'm unable to resolve hostnames (ping fails, for example). In fact, I can't even ping valid IP addresses ("Destination Host Unreachable").

Although ifconfig seems to reflect all the settings I put in /etc/network/interfaces, I am unable to access the Internet whatsoever, nor can I access the machine using SSH or FTP from another machine.

Here's my /etc/network/interfaces:

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

auto eth0
iface eth0 inet static

Here's what ifconfig gives me:

eth0      Link encap:Ethernet  HWaddr 00:25:90:57:7c:65
          inet addr:  Bcast:  Mask:
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:20 Memory:fba00000-fba20000

eth1      Link encap:Ethernet  HWaddr 00:25:90:57:7c:64
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::225:90ff:fe57:7c64/64 Scope:Link
          RX packets:252 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:54010 (54.0 KB)  TX bytes:15731 (15.7 KB)
          Interrupt:16 Memory:fb900000-fb920000

lo        Link encap:Local Loopback
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:94 errors:0 dropped:0 overruns:0 frame:0
          TX packets:94 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:8088 (8.0 KB)  TX bytes:8088 (8.0 KB)

Why is this happening and how can I fix it?

share|improve this question
up vote 1 down vote accepted

If you are using a desktop version of Ubuntu, with a graphical network-manager tool installed, then you should not define the connection in the /etc/network/interfaces file.

Instead, open the connection via the nm-applet on the desktop (or by invoking nm-connection-editor from a terminal), navigate to the IPv4 settings tab, and set the connection mode to Manual using the drop-down selection box. Then add your desired IP and DNS settings in the boxes provided.

You should then revert any edits to your /etc/network/interfaces file (so that it contains only the lo definition lines) and either restart both the networking and network-manager services or reboot the machine.

You should also make sure that the chosen static IP address is outside the DHCP pool assigned by your router - in fact, you may find it simpler to keep a DHCP configuration on the machine, and reserve a particular IP for it on the router, if it supports DHCP address reservation.

If you really want to keep the GUI network-manager, but define your interface via /etc/network/interfaces, then you could try editing /etc/NetworkManager/NetworkManager.conf, changing




and then making sure there are no other competing connections defined in the /etc/NetworkManager/system-connections/ directory (where 'competing' means 'using the same interface as'). This should allow you to see and control the connections in /etc/network/interfaces under the GUI network-manager applet.

Alternatively you could remove the network-manager package altogether.

share|improve this answer
What I'm using is actually Xubuntu on a machine designed specifically to run as a server. It does have a GUI which I can access if I have to, but generally I just access it via SSH from another computer. That's the reason I'm trying to do this all through command line. Are you just saying it's easier to use the GUI, or are you saying that the presence of the GUI nullifies the /etc/network/interfaces method? – Parker Kemp Sep 25 '13 at 1:28
It doesn't nullify it exactly, however the two different services are known not to play well together. – steeldriver Sep 25 '13 at 1:44
OK, I've opted to uninstall network-manager via sudo apt-get purge network-manager. I rebooted, and am still having the same issues. eth1 no longer shows up under ifconfig (which I expected), but it still can't seem to connect via eth0. You mentioned making sure the IP address is outside of the DHCP pool of the router... I was unaware this was a factor. How can I figure out the range of the DHCP pool, and just out of curiosity, why does this matter? – Parker Kemp Sep 25 '13 at 4:00
If your static IP is not outside the router's address pool, then there's nothing to stop it assigning the same IP to another host via DHCP, which will cause an addressing conflict. You would need to go into your router's management web interface to check that, however if it's just a small home LAN then an address conflict is unlikely. Can you narrow down where the connection is failing i.e. can you ping your gateway / router by IP? ping another host in the LAN by IP? ping an external host by IP? and by name? ping everywhere but not browse the internet? – steeldriver Sep 25 '13 at 11:50
Well this isn't the best forum for step-by-step troubleshooting but the first thing that stands out is that your original (presumably functional) DHCP connection using network-manager was eth1 not eth0 - so do you have 2 physical ethernet ports? are you sure you're plugged in to the same one you are configuring? Are you sure both work? Perhaps changing eth0 to eth1 in /etc/network/interfaces is all that's required. – steeldriver Sep 25 '13 at 13:32

You need to add your DNS configuration directly on /etc/network/interfaces:

auto eth0
iface eth0 inet static
share|improve this answer
I just tried this, but it doesn't seem to change anything. When I restart, it refuses to connect to eth0 at all (according to the GUI). When I click "Auto Ethernet", it instead connects to eth1 using DHCP. I just added the ifconfig output to my answer if that helps. – Parker Kemp Sep 25 '13 at 0:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.