How to specify two or more gateways in dnsmasq
Asked Answered
S

2

5

I am using Dnsmasq on ubuntu12.04 for DHCP server.And in my LAN that has two routers,then I want to specify two gateways address for different devices.So does it support this function? And if it support, how to specify?

Singspiel answered 5/4, 2015 at 2:33 Comment(0)
S
10

all.After trying it, I fix it by anther thread.The thread is here:

  • To set tag in dhcp-range

    dhcp-range=set:tag0,192.168.1.2,192.168.1.150,infinite
    dhcp-range=set:tag1,192.168.1.151,192.168.1.245,infinite
    
  • To specify mac address and host ip

    dhcp-host=11:22:33:44:55:66,hosta,192.168.1.11,infinite
    dhcp-host=66:55:44:33:22:11,aa:bb:cc:dd:ee:ff,hostb,192.168.1.12,infinite
    
  • To set tag in options file.

    dhcp-option=tag:tag0,option:router,192.168.1.1
    dhcp-option=tag:tag1,option:router,192.168.1.2
    

Then, I find that it's works. I hope these can help others!

Singspiel answered 8/4, 2015 at 9:33 Comment(0)
S
5

all.I fixed it(wrt specify two or more routers in the same subnet) and I will post what I have got here in case it can help someone else. My requirement was handing out different routers to different hosts in the same subnet.

dhcp-range=set:tag0,192.168.1.2,192.168.1.200,infinite

# tag0 network
dhcp-host=11:22:33:44:55:66,hosta,192.168.1.11,infinite,set:tag0
dhcp-host=66:55:44:33:22:11,aa:bb:cc:dd:ee:ff,hostb,192.168.1.12,infinite,set:tag1

Then, to specify different routers to different hosts.

# options
dhcp-option=tag:tag0,option:router,192.168.1.1
dhcp-option=tag:tag1,option:router,192.168.1.2

some other notes / context that i found helpful about this, and also about the net / set / tag options:

  • The optional set: sets an alphanumeric label which marks this network so that dhcp options may be specified on a per-network basis. When it is prefixed with 'tag:' instead, then its meaning changes from setting a tag to matching it. Only one tag may be set, but more than one tag may be matched.
  • More than one tag can be set in a dhcp-host directive (but not in other places where "set:" is allowed)
  • This system evolved from an earlier, more limited one and for backward compatibility "net:" may be used instead of "tag:" and "set:" may be omitted. (Except in dhcp-host, where "net:" may be used instead of "set:".) For the same reason, '#' may be used instead of '!' to indicate NOT.

therefore i think it's safe to just:

  • use set and tag, and avoid using net (since it's the old way)
  • use set in your dhcp-range and dhcp-host, to assign the tags, and
  • use tag in your options to match the tags that you've already set.
  • as an aside on of those dhcp-hosts you can see with multiple mac addresses, because it's the eth0 and wlan mac's for the same box.

seems to work for me anyway, perhaps this will help someone.

Singspiel answered 7/4, 2015 at 5:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.