The same network interfaces interfaces in my laptop (eth1, wifi0, br0) are often connected to different networks (home/work/university network, virtual network with Virtualbox, ad-hoc network with my laptop as router), so dhcpd
can listen to various combinations of interfaces.
I want it to run for ad-hoc and virtual networks, but not to "big" networks which already have dhcp server. So in my network configuration scripts there is often killall dhcpd; dhcpd -i some_interface
(or just killall dhcpd
), which makes them interfere each other.
How to dynamically change listen interfaces in dhcpd
or run multiple instances.
Or I should make it just listen to all interfaces but manage iptables
rules to prevent dhcpd interference in scripts instead?
YOur laptop shouldn't be providing DHCP services to other computers if it is moving around. That being said, you may want to provide services to virtual box instances on your laptop. Consider setting up the br0 interface not to bridge to an external network and use iptables to do the routing. Configure DHCP to only listen on the interface.
If you want to route an ad-hoc network and provide DHCP then create another dchpd configuration for it. It should only listen on wifi0 (the ad-hoc interface). Bring it up when in your ad-hoc configuration, and bring if down when you disable ad-hoc networking.
You will likely need to get IP addresses on eth1 and wifi0, so it is dangerous to enable DHCP on them.