All statically assigned addresses, but dhcpcd still runs?
I have a VM (on ESXi 5.1.0) running Debian Wheezy (7.0).
eth0 has a statically assigned address. eth1 was DHCP-assigned, and now I want to make it static.
Here is my old /etc/network/interfaces:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo eth0 eth1
iface lo inet loopback
# The primary network interface
allow-hotplug eth0 eth1
iface eth0 inet static address 10.2.1.77 broadcast 10.2.1.255 netmask 255.255.255.0 pointopoint 10.2.1.1
iface eth1 inet dhcpAnd here is my new /etc/network/interfaces:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo eth0 eth1
iface lo inet loopback
# The primary network interface
allow-hotplug eth0 eth1
iface eth0 inet static address 10.2.1.77 broadcast 10.2.1.255 netmask 255.255.255.0 pointopoint 10.2.1.1
iface eth1 inet static address 10.1.0.254 netmask 255.255.255.0 gateway 10.1.0.1 dns-nameservers 8.8.8.8When I reboot, I can see dhcpcd try to renew my lease for my old DHCP-assigned address, and succeed. And then it overwrites /etc/resolv.conf, which should contain 8.8.8.8 but does not. eth1 does have the correct (static) address, however.
What am I doing wrong here? I don't want to disable dhcpcd outright. In the near future I might switch eth1 back to DHCP, or add a third DHCP-assigned interface.
5 Answers
Run (as root):
update-rc.d -f dhcpd remove
If you want to re-enable it in the future,
update-rc.d dhcpd defaults
NOTE: Removing it from rc.d will disable it on all interfaces. Restoring it will enable on all interfaces.
4If you are using dhcpcd (the client daemon, most people here are confusing it with DHCP and DHCPd which is different), then add the following text on the bottom of /etc/dhcpcd.conf
static
interface eth0
static ip_address=172.16.0.5/24
static routers=172.16.0.1
static domain_name_servers=8.8.8.8Of course remember to replace the IP info with your network details.
1The man page for dhcpcd tells us:
denyinterfaces pattern
When discovering interfaces, the interface name must not match pattern which is a space or comma separated list of patterns passed to fnmatch(3).
To stop dhcpcd from operating on an interface(s), you can ask it to leave the interface alone by adding the a line to /etc/dhcpcd.conf.
in the OPs case this would be:
denyinterfaces eth0This should stop dhcpcd messing with you on that specific interface while leaving dhcpcd enabled. This also lets you keep your interface configuration in /etc/network/interfaces. The other option is using what Ariffer suggested (Using /etc/dhcpcd.conf to do your config instead of /etc/network/interfaces.)
You could disable the service.
The preferred method would be to update the /etc/sysconfig/network-scripts/ifcfg-* file for the device removing the dhcp line (or altering it to false)
Unfortunately I'm not in front of my linux machine right now so I can't pull the exact configuration for you.
3This is caused by a limitation in dhcpcd5 - it enables DHCP on all interfaces (all or nothing). I fixed this by switching to isc-dhcp-client which is more flexible.