Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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.

share|improve this answer
    
Usually dhcpd listens wifi0 (which runs hostapd) and actually does rounting by iptables (-j REDIRECT and -j MASQUERADE). Bridge is used to use several MAC/IP pairs simultaneously or to connect virtual network to physical. But for example when I experiment with PXE I also need it to listen to eth1, veth1, br0 in addition to wifi0. (eth1 is direct connection to test computer). –  Vi. Jun 23 '10 at 22:54
    
Also I configured my dhcpd to give leases with short duration (about 2 minutes) and thing it will minimize troubles if dhcpd accidently will listen the wrong network. Will computers obtain addresses again from normal DHCP server after 2 minutes when I turn off the wrong one? –  Vi. Jun 23 '10 at 22:57
    
In general, I connect my laptop to many networks (some test, some production), and also use it both as usual laptop, for development and (sometimes) as wireless access point [simultaneously]. This is why it is all that complex. –  Vi. Jun 23 '10 at 22:59
    
Short leases won't help get computers back on the right network. Leases are retries at half the lease time so try a longer lease. DHCP tries the same server first. Make sure you mark your server as non-authoritative on any interface connected to a public network. This will encourage computers to get their lease from the authoritative server. You didn't mention if you have eth0. If so reserve this for public networks. You can then run DHCP on eth1 all the time. –  BillThor Jun 24 '10 at 14:07
    
If you have eth0 for public networks, your only problem interface is wifi0. A program which monitors whether eth0 is connected might be able handle switching your wifi0 connection to the proper mode. If you provide hostap into an isolated network, you will need a different method to do the switch. You may want to use the 172.16.0.0/12 block or a higher numbered B block in the 192.168.0.0/24 range to isolate your network(s). –  BillThor Jun 24 '10 at 14:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.