When I upgraded from Ubuntu 8.04 (Hardy) to Ubuntu 8.10 (Intrepid), a dhclient-exit-hook script I wrote no longer functioned.
dhclient-script was previously used by dhclient so that whenever the dhcp changed, it would reconfigure the interfaces, generate the /etc/resolv.conf, and run scripts who’s intention is to modify the /etc/resolv.conf file based on the dhcp settings. These scripts are located in the folders /etc/dhcp3/dhclient-enter-hooks.d/ and /etc/dhcp3/dhclient-exit-hooks.d/.
Reading up on the problem, thanks to perlhead on the Ubuntu Forums, it appears that since NetworkManager did the same function as dhclient-script, which got in the way of NetworkManager’s plugins, so dhclient-script was disabled.
Sadly NetworkManager fails to call any hooks on dhcp renew, which is what my script needed. It only calls its hooks, which are located in /etc/NetworkManager/dispatcher.d/, when the interface is brought up or down.
I’ve made a modified dhclient-script, which when set as the dhclient script, will call the enter hooks, then call NetworkManager’s dhclient script, then call the exit hooks. This effectively gives the intended effect of allowing NetworkManager to run with the old dhcp hooks available.
To use it, modify your /etc/dhcp3/dhclient.conf and add/modify the line:
And save this file /sbin/dhclient-script-networkmanager
Make sure its executable:
chmod +x /sbin/dhclient-script-networkmanager
Apparmor is included in Ubuntu 9.04, which will block execution of this script, what you can do is update the apparmor dhclient profile to allow the new script location, edit “/etc/apparmor.d/sbin.dhclient3″ and replace all occurances of /sbin/dhclient-script with /sbin/dhclient-script-networkmanager, and it should now work.
Now restart NetworkManager to see if it has worked:
sudo /etc/init.d/NetworkManager restart
Wait for the network to reconnect again, if it hangs then it probably didn’t work. Check out your resolv.conf:
Please let me know how it goes when running this script. I have only tested it on Ubuntu 8.10 and 9.04.