How can I ensure that my static ip address is read from /etc/network/interfaces rather than dhcp?

Posted by jonderry on Super User See other posts from Super User or by jonderry
Published on 2014-06-05T18:55:07Z Indexed on 2014/06/05 21:29 UTC
Read the original article Hit count: 179

Filed under:
|
|

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?

© Super User or respective owner

Related posts about linux

Related posts about networking