Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This is a follow up to the following question. I'm trying to set a static IP by changing /etc/network/interfaces to the following:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
  address 192.168.2.133
  netmask 255.255.255.0
  gateway 192.168.2.1
  dns-nameservers 8.8.8.8

and then running /sbin/ifdown eth0; /sbin/ifup eth0. However, the change in IP address doesn't appear to take effect without editing /etc/dhcp/dhclient.conf and commenting out the following before running ifdown; ifup:

request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        dhcp6.name-servers, dhcp6.domain-search,
        netbios-name-servers, netbios-scope, interface-mtu,
        rfc3442-classless-static-routes, ntp-servers,
        dhcp6.fqdn, dhcp6.sntp-servers;

Strangely, after commenting out this line, running ifdown; ifup works, but when I uncomment it, the behavior does not revert to the previous behavior of ignoring changes to my settings in /etc/network/interfaces (this doesn't seem like a problem, but I really need to be able to repeat this problem so that I can be confident that my solution is robust) Also, I'd rather not have to edit /etc/dhcp/dhclient.conf to change my static IP since it seems I should be able to do this by only editing interfaces.

Can anyone explain the issues I'm seeing above and suggest the best way of making changes to static IP addresses take effect that admits reproducibility so that I can be sure that my approach works?

share|improve this question

2 Answers 2

You need to make sure that dhclient isn't still running, and issuing an ip to eth0 when it comes back up.

Check for dhclient:

ps aux | grep dhclient

If running, kill it, then perform ifdown; ifup.

share|improve this answer
    
Do you know how I can reproduce the issue I was having previously? I'd like to get back into the state I was in previously, where setting the static IP address had no effect so that I can be sure that this approach works. –  jonderry Jun 5 at 21:08
    
Figured it out. I can't remember exactly the previous state I was in, but I can somewhat reproduce by calling sudo ip addr flush dev eth0; sudo dhclient eth0. Then I execute ifdown; ip addr flush dev eth0; ifup to load whatever static ip is set in /etc/network/interfaces. –  jonderry Jun 5 at 23:01

If your system has an /etc/network/interfaces file, then it's Debian-based and it probably has Network Manager, which a) famously ignores the interfaces file and b) runs dhclient without being asked, even when a device is running and working the way you want it to.

Newer versions of NetworkManager are supposed to ignore devices that have manual or static configurations. Good luck with that.

Network Manager is great for laptops or any PC with a wifi card. On a desktop PC with LAN-based ethernet, it causes more problems than it solves, IMHO.

Three solutions I have seen, pick the one that most suits:

  1. $ sudo su -c 'echo manual > /etc/init/network-manager.override'
  2. Add the line NM_CONTROLLED=no to the device stanza (this seems more RHEL style)
  3. $ sudo apt-get remove --purge network-manager
share|improve this answer

Your Answer

 
discard

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.