OpenWrt Forum Archive

Topic: DHCP Option 3

The content of this topic has been archived on 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi Guys,
I am desperately trying to get a DHCP client to use a different Default Gateway than the rest of my DHCP clients.

I have made a static lease for the client and I try to use DHCP option 3 to achieve it. It doesn't set the default gateway on the client though...It sets the IP but it keeps the standard default gateway of 192.168.1.2 as all the other clients....

This is from the DHCP config:

config host
        option ip                '192.168.1.200'
        option mac            '98:5f:d3:5c:13:4c'
        option name          'Surf1'
        list 'dhcp_option'   '3,192.168.1.1'

Does anyone know why this do not work?

Best
Lars

Lars,
that option should be added to "config dhcp 'lan'".

stangri wrote:

Lars,
that option should be added to "config dhcp 'lan'".

Hi stangri,
Thanks for the info, but that would affect all of the DHCP clients then, correct? I just want to change the default gateway on one of them. Isn't that possible?

Best
Lars

(Last edited by wereallinittogether on 25 Dec 2016, 18:04)

Ah, right, sorry, I do that sometimes -- read half a question. sad

dhcp-mac + dhcp-option settings for dnsmasq should work. I've checked out the init script for LEDE and all 3 are supported there, not sure about OpenWrt. I've never used it myself, so try to google/experiment for proper syntax.

Dnsmasq is flexible enough. And I tested openwrt scripts can also use tags. This is how its supposed to be :

config dhcp 'lan'
        list dhcp_option 'tag:static,3,192.168.2.7'
config host
        option tag static

Tag name can be whatever you want. Dhcp options with "tag:" apply only to hosts tagged with specified tag and ignored for other hosts. Can also use negation "tag:!static".

Or use this :

config host
        option tag static
config tag 'static'
        list dhcp_option '3,192.168.2.7'

In the last syntax negation seem not to be supported.

http://www.thekelleys.org.uk/dnsmasq/do … q-man.html
https://wiki.openwrt.org/doc/uci/dhcp

(Last edited by bolvan on 26 Dec 2016, 12:24)

Hi Bolvan,
Cannot get the tags to work unfortunately. Here is my dhcp config:

config host
        option family 'ipv4'
        option name 'SURFACE'
        option mac '98:5f:d3:5c:13:4c'
        option ip '192.168.1.3'
        option tag 'yousee'
config tag 'YouSee'
         list dhcp_option '3,192.168.1.1'
config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option filterwin2k '0'
        option localise_queries '1'
        option rebind_protection '0'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option nonegcache '0'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.auto'

config domain
        list name 'www.routerlogin.net'
        list name 'routerlogin.net'
        list name 'www.routerlogin.com'
        list name 'routerlogin.com'
        list name 'www.login.lan'
        list name 'login.lan'
        list name 'login'
        list name 'inteno.lan'

config dhcp 'lan'
        option interface 'lan'
        option dhcpv6 'server'
        option ra 'server'
        option ra_management '1'
        option start '100'
        option limit '150'
        option leasetime '12h'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'

config tag 'YouSee'
         list dhcp_option '3,192.168.1.1'

config host
        option family 'ipv4'
        option name 'SURFACE'
        option mac '98:5f:d3:5c:13:4c'
        option ip '192.168.1.3'
        option tag 'YouSee'

(Last edited by wereallinittogether on 27 Dec 2016, 15:38)

Did you restart dnsmasq ?
Check /var/etc/dnsmasq.conf

bolvan wrote:

Did you restart dnsmasq ?
Check /var/etc/dnsmasq.conf

You are the man! It worked. Thanks a bunch guys!

The discussion might have continued from here.