I got one of my Raspberry Pi servers attempting to obtain DHCP IP address, a behavior that ignored my static IP address configuration.
Not sure why, but it appeared I'd be getting an extra DHCP address, from the same network segment, in addition to the static IP the Raspberry Pi already had.
Normally I'd just disable the service, but since my home office network is fairly static, I figured I would just remove the DHCP package.
WARNING: do not follow my steps unless you're in the same situation and pretty sure you're using static IP addressing.
Double Check that You're Using Static IP
Check your /etc/network/interfaces file, it should have something similar for your primary interface – in wired network cable case it's eth0:
auto eth0 iface eth0 inet static address 192.168.1.99 netmask 255.255.255.0 gateway 192.168.1.1
Also, run ip a and make sure you're seeing this same IP among the active interfaces:
greys@s7:~ $ ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether b8:27:ee:66:88:ff brd ff:ff:ff:ff:ff:ff inet 192.168.1.99/24 brd 192.168.1.255 scope global eth0 valid_lft forever preferred_lft forever
Remove ISC DHCP Client
So I did this:
root@srv:~# apt-get remove isc-dhcp-client Reading package lists… Done Building dependency tree Reading state information… Done The following packages were automatically installed and are no longer required: libdns-export1104 libisc-export1100 Use 'apt autoremove' to remove them. The following additional packages will be installed: dhcpcd5 Suggested packages: dhcpcd-gtk The following packages will be REMOVED: isc-dhcp-client The following NEW packages will be installed: dhcpcd5 0 upgraded, 1 newly installed, 1 to remove and 207 not upgraded.
All cool? Not really. If you read carefully, you'll notice that I removed isc-dhcp-client, but automatically installed dhcpcd5 – which started making DHCP requests again.
Remove DHCPcD5
Next step then! Let's remove DHCPcD5:
root@srv:~# apt-get remove dhcpcd5 Reading package lists… Done Building dependency tree Reading state information… Done The following additional packages will be installed: isc-dhcp-client Suggested packages: avahi-autoipd isc-dhcp-client-ddns The following packages will be REMOVED: dhcpcd5 The following NEW packages will be installed: isc-dhcp-client 0 upgraded, 1 newly installed, 1 to remove and 207 not upgraded.
Much better!
Or is it? If you look closer, you'll see that this command installed isc-dhcp-client back.
Delete both DHCP Client Packages
This time I specified both packages to be removed. I even used apt-get purge instead of apt-get remove – to definitely destroy any configs:
root@srv:~# apt-get purge dhcpcd5 isc-dhcp-client Reading package lists… Done Building dependency tree Reading state information… Done The following packages were automatically installed and are no longer required: libdns-export1104 libisc-export1100 Use 'apt autoremove' to remove them. The following additional packages will be installed: pump The following packages will be REMOVED: dhcpcd5* isc-dhcp-client* The following NEW packages will be installed: pump 0 upgraded, 1 newly installed, 2 to remove and 207 not upgraded.
When this installed pump (that's apparently another BOOTP/DHCP client – I never even heard about it before), I got curious.
Having researched online, it appears one can configure static IP in Raspberry Pi using DHCP client configs. Doesn't sound right to me! There's also the systemd way to disable dhcpd.service, but at this stage I was not looking for half measures.
Having carefully considered this, I decided to unstall the whole lot. It also removed wicd* (Wired and Wireless Network Connection Manager) bunch which is another set of packages for managing network interfaces and connections.
I'm honestly suprised and seriously suprised how involved a network interface and IP address configuration is! Since I'm not using any of these niceties and because this is a static server-like environment where I'm not switching Wi-Fi networks or changing connection profiles all the time, I'm comfortable letting it all go.
Uninstalling DHPCP clients, pump and Wicd
WARNING: be super sure you're using static IP addressing on your Raspberry Pi system before running the next command.
Here's the final uninstall command:
root@s7:~# apt-get remove dhcpcd5 isc-dhcp-client pump Reading package lists… Done Building dependency tree Reading state information… Done Package 'isc-dhcp-client' is not installed, so not removed Package 'pump' is not installed, so not removed The following packages were automatically installed and are no longer required: libdns-export1104 libisc-export1100 openresolv python-wicd Use 'apt autoremove' to remove them. The following packages will be REMOVED: dhcpcd5 wicd wicd-daemon wicd-gtk 0 upgraded, 0 newly installed, 4 to remove and 207 not upgraded.
FINALLY! No more DHCP requests from this server 🙂
pS: on a somewhat relevant note, think I'll upgrade all them 207 packages – but first will complete a reboot to check network configuration still works for the static IP.
Leave a Reply