All statically assigned addresses, but dhcpcd still runs?
Solution 1
This 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.
Solution 2
The 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 eth0
This 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.)
Solution 3
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.
Solution 4
If 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.8
Of course remember to replace the IP info with your network details.
Related videos on Youtube
craig65535
Software developer. Experienced with network security, macOS/Linux systems software, macOS/Linux kernel development, mobile development (iOS and Android). Languages: C/C++, Swift, Perl, Java, C#/.NET. Other technologies: git, SQL, bash, autoconf/automake, Xcode, Eclipse, vim, POSIX
Updated on September 18, 2022Comments
-
craig65535 over 1 year
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 dhcp
And 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.8
When 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. -
craig65535 over 11 yearsUnfortunately
/etc/sysconfig
does not exist on Debian. Or at least on my install. -
Goldus over 11 yearsI should also mention that doing both wont hurt anything unless you plan on adding a NIC that will use DHCP.
-
Goldus over 11 yearsMy appologies. I've only ever encountered this problem when using network manager on the command line. After a quick google it appears those files are part of NetworkManager configuration opposed to what you are using.
-
craig65535 over 11 yearsSo it's all interfaces or no interfaces? Is there a way to use an alternative dhcp client?
-
Kruug over 11 yearsAs far as I am aware, yes. I don't know much about Linux, sadly.
-
craig65535 over 11 yearsSo I was using the
dhcpcd5
package. Looks like there are lots of alternatives:dhcpcd
,udhcpc
,isc-dhcp-client
andpump
are some of them. -
geerlingguy about 8 yearsThis was helpful reminding me that I needed to do the same thing on
wlan0
on my Raspberry Pi when I wanted to switch to manual/static IP on Raspbian Jessie, which runs DHCPd by default. No need to uninstall it completely as long as you configure/etc/dhcpcd.conf
correctly. -
Admin almost 2 yearsYour answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.