Getting burned by dhclient
A member switched from a dynamic IP address to a static IP address yesterday - very exciting! And most remarkable - the switch was extremely smooth. On our debian router, I simply:
Edited /etc/network/interfaces, changing “dhcp” to “static” and added the lines in the stanza with the new static information
Restarted the interface:
ifdown wan; ifup wan
And presto it was working!
Until the next day when the Internet was down. Crap. I’m very proud of the staff person I spoke to who went through the steps of logging in and reading back the output of /sbin/ifconfig, indicating the the wan interface wasn’t assigned an IP address. She re-ran the command to bring down the interface and bring it back up and again we were back on line.
After logging in myself, I started grepping through syslog. It was really difficult because of all this dhclient noise. I started fashioning a grep command to eliminate the dhclient stuff when it dawned on me:
I never turned off the dhclient.
So, in the middle of the night, dhclient, blissfully unaware of the new static IP address, asked the world for a new IP address, didn’t get a response, and set the wan interface to not have an IP address at all.
So, for future reference, the proper order of operations should have been:
- Bring down the wan interface (and dhclient with it):
Edit /etc/network/interfaces to change the dhcp to static
Bring up the wan interface
For the curious - I killed the dhclient with:
ps aux | grep dhclient
This returns the PID as the number in the second column