Re: Is there a way to pass my script to the DHCP client in NetworkManager?

On Tue, 2012-06-26 at 11:34 -0600, Chengyu Fan wrote:
> Hi~
> I want to assign some job to my DHCP client (not just configure the
> network interface). Ex: I let my DHCP client request some private
> options(224-254), if I get those options another program should run,
> otherwise just do the regular IP configuration.
> But the DHCP client is under the control of NetworkManager. Does
> anyone know that if there is a way to pass a new script to the DHCP
> client in the NetworkManager? Or if I can configure the NetworkManager
> to create a new script?

If you have interface-specific options and you're on Fedora, you can put
those options into interface config files, eg /etc/dhclient-eth0.conf
or /etc/dhcp/dhclient-eth0.conf.  The other distros, for whatever
reason, don't have interface-specific config files by tradition, so you
all your interfaces have to share the config for your specific options.
That goes in /etc/dhcp/dhclient.conf (Debian, Gentoo)
or /etc/dhclient.conf (SUSE).

NM reads this file and copies its contents to the actual config file it
sends to dhclient.  So feel free to drop your custom 'also request'
stuff and custom 'option' formats there, and NM will use them.

NM will call various scripts called "dispatcher" scripts on network
events, like network up and network down.  So if you'd like your script
to run when the network is ready (IP addressing complete) you can do
that, and you'll also get all your DHCP options including the private
ones in the script's environment.  See 'man NetworkManager' for that.

Does that do what you need it to?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]