Set gateway per interface in DNSMasq

I have dhcp set up using DNSMasq, which looks like this:

dhcp-range=interface:eth0,10.1.0.50,10.1.0.250,255.255.255.0
dhcp-range=interface:eth1,10.1.20.50,10.1.20.250,255.255.255.0

What I need to be able to do is set the gateway 'dhcp-option 3' for each interface separately, which I expected would look like this:

dhcp-option=interface:eth0,3,10.1.0.254
dhcp-option=interface:eth1,3,10.1.20.254

However, this does not work. What would be the correct way of setting up independent gateways on a per-interface basis?


Solution 1:

It stands to reason that the syntax in the question would make sense. However, it is even simpler than that:

dhcp-option=eth0,3,10.1.0.254
dhcp-option=eth1,3,10.1.20.254

[Edit] After a couple years of this in use, I'm reporting a problem with this setup. Say you have a public and a secure network, both accessible via WiFi. If your device connects to the public network, but you wish to switch to the secure one, your device and the DHCP server will try to re-use your address lease from the public network, resulting in an invalid address for the subnet you now occupy. This could probably be fixed by setting lease time to zero, but that may have other adverse effects depending on your network requirements (network printer addresses, etc).