On Wed, 2012-06-27 at 16:14 -0600, Chengyu Fan wrote: > > > On Wed, Jun 27, 2012 at 3:09 PM, Dan Williams <d...@redhat.com> wrote: > 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. > > > Thanks for your answer. > I think this is what I need. > > > One more question: > In DHCP, it is the "script-file" ( which is specified by -sf) to get > the parameters and commit the actual configuration. I'd like to run my > script or program after the network is ready, but how can I get the > new DHCP options in "dispatcher"? Ex: $new_domain_name, > $new_ip_address, et al.
They are given in the environment of the script, as described by 'man NetworkManager', which says: --- If the connection used DHCP for address configuration, the received DHCP configuration is passed in the environment using standard DHCP option names, prefixed with "DHCP4_", like "DHCP4_HOST_NAME=foobar". --- The same also happens for DHCPv6, but obviously with a different prefix. Dan _______________________________________________ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list