Force dnsmasq to bind an interface for DHCP

dhcpdnsmasqinterfacesocket

I want to use dnsmasq with two configs on two interfaces, which should be bound locally. If you read the manpage, it looks like interface=wlan0 bind-interfaces should do the trick. But it always binds the dhcp server to all interfaces:

udp        0      0 192.168.101.1:53        0.0.0.0:*                           0          7410711     22333/dnsmasq   
udp        0      0 0.0.0.0:67              0.0.0.0:*                           0          7410708     22333/dnsmasq 

Config:

interface=wlan0
except-interface=lo
except-interface=wlan0_0
no-dhcp-interface=wlan0_0
dhcp-range=interface:wlan0,192.168.101.2,192.168.101.255,60m
bind-interfaces

Commandline: dnsmasq -C /etc/dnsmasq.wlan0.conf -z

Many of the options should be redundant in theory, but in practice it still binds to 0.0.0.0:67.

Best Answer

You can do everything you want with one instance. This is an example based on a configuration I have used.

# DHPC ranges set tag
dhcp-range=set:able,192.168.20.10,192.168.20.100,255.255.255.0,48h
dhcp-range=set:baker,192.168.30.10,192.168.30.100,255.255.255.0,192h

# Tag dependent options
dhcp-option=able,3,192.168.20.1           # Router
dhcp-option=able,15,able.example.com      # Domain
dhcp-option=baker,3,192.168.20.1          # Router
dhcp-option=baker,15,baker.example.com    # Domain

# Common settings
dhcp-option=6,192.168.20.2,192.168.30.2   # DNS servers
dhcp-option=19,0                          # Option ip-forwarding off
dhcp-option=20,0                          # Source routing off
dhcp-option=27,1                          # All sub-nets are local
dhcp-option=31,0                          # Router Discovery off
dhcp-option-force=42,192.168.20.5         # NTP time servers
dhcp-option=119,able.example.com,example.com # Search List

This is covered in the man page.

Related Topic