Static leases with different DNS servers

Hi,

Is there any reason, why configuration like this in the /host/config/dhcp file

config host
option name 'mylaptop' # Hostname (optional, for reference)
option mac '11:22:33:44:55:66' # MAC address of the client
option ip '192.168.1.101' # Static IP to assign to the client
option dns '192.168.1.10' # Custom DNS server for this client*

could doesn't work, means custom DNS server is not assigned to the 'mylaptop' client?
Client still uses the default DHCP's DNS server..
Instead of 'option dns' I tried to use also
list dhcp_option '6,192.168.1.10'

In this way I would like to assign local custom DNS server (later also IPv6) to few DHCP clients, while keeping default external one for all others.

Thank you for any ideas...

Regards,
Franek

https://openwrt.org/docs/guide-user/base-system/dhcp_configuration#client_classifying_and_individual_options

That's not how it works, dns is a boolean telling OpenWrt to add it to the name server table so you can nslookup mylaptop. Details at https://openwrt.org/docs/guide-user/base-system/dhcp#static_leases

What you are looking for is probably in that same document, look at the sections above the one I linked.

Looks nice and simple... but doesn't work for me, still client use global one...
I've defined the tag1

dhcp.tag1=my_DNS
dhcp.tag1.dhcp_option='6,192.168.1.10' '23,fdaf:XXXX:XXXX:X:XXXX:XXXX:XXXX:XXX'

Added tag1 to few clients in Static Leases, but still they don't use 192.168.1.10, IPv6 one.. :frowning:

Post the dnsmasq config from /etc/config, mask any MACs.

See: https://github.com/egc112/OpenWRT-egc-add-on/tree/main/stop-dns-leak#option-6

That works for me

Thanks. Executed uci commands following

https://openwrt.org/docs/guide-user/base-system/dhcp_configuration#client_classifying_and_individual_options

... added almost the same configuration to my /etc/config/dhcp, except 'option dhcp_option...', but neither works with 'list dhcp_option...'

config my_DNS 'tag1'
        option dhcp_option '6,192.168.1.10' #neither works with list dhcp_option

config host
        option name 'myLaptop'
        option leasetime 'infinite'
        option ip '192.168.1.8'
        list mac 'F0:DD:DD:DD:DD:DD'
        list tag 'tag1'

Sure, here is my /etc/config/dhcp, hidden MACs, changed used subnet), for the test purpose I've removed all other leases.


root@router:~# cat /etc/config/dhcp

config dnsmasq
	option domainneeded '1'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/lan/'
	option domain 'lan'
	option expandhosts '1'
	option cachesize '1000'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
	option localservice '1'
	option ednspacket_max '1232'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '200'
	option leasetime '12h'
	option dhcpv4 'server'
	option dhcpv6 'server'
	option ra 'server'
	list ra_flags 'managed-config'
	list ra_flags 'other-config'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

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

config myDNS 'tag1'
	option dhcp_option '6,192.168.1.10'

config host
	option name 'myDNSsrv'
	option leasetime 'infinite'
	option ip '192.168.1.10'
	option dns '1'
	list mac 'E0:DD:DD:DD:DD:DD'

config host
	option name 'myLaptop'
	option leasetime 'infinite'
	option ip '192.168.1.8'
	list mac 'F0:DD:DD:DD:DD:DD'
	list tag 'tag1'

config host
	option name 'AnotherDevice'
	option leasetime 'infinite'
	option ip '192.168.1.12'
	list mac 'D0:DD:DD:DD:DD:DD'
	list tag 'tag1'
root@router:~# 


Client always receive router's IP as DNS, not my own DNS

Link 3 (wl...)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.1.1
       DNS Servers: 192.168.1.1 fdaf:DDDD:DDDD::1
        DNS Domain: lan

The same in windows...

See the correct syntax.

If you want to name the tag section my_DNS, the config should look like this:

config tag 'my_DNS'
        option dhcp_option '6,192.168.1.10'

config host
        option name 'myLaptop'
        option leasetime 'infinite'
        option ip '192.168.2.8'
        list mac 'F0:DD:DD:DD:DD:DD'
        option tag 'my_DNS'
2 Likes

Seems works!

uci commands I used to create a TAG generated code as I shared.
Then I used LUCI to set the tag on existing leases.
Maybe here discrepancy appears?

When manually I've corrected syntax directly in /etc/config/dhcp as you suggested, everything started to work for tagged clients.

Thanks a lot, you and everyone who responded.
Appreciate!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.