Getting burned by dhclient

2007-01-08 2-minute read

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:

  1. Edited /etc/network/interfaces, changing “dhcp” to “static” and added the lines in the stanza with the new static information

  2. 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:

  1. Bring down the wan interface (and dhclient with it):
ifdown wan
  1. Edit /etc/network/interfaces to change the dhcp to static

  2. Bring up the wan interface

ifup wan

For the curious - I killed the dhclient with:

ps aux | grep dhclient

This returns the PID as the number in the second column

Then:

kill