Q: Push specific DNS nameserver over DHCP?

Hi,

I need to have OpenWRT push a specific name server to DHCP clients on the wireless interface whose nameservers can only be set using DHCP.

Currently it pushes 192.168.1.1 which is itself.

How, for example, can I get it to push only 1.1.1.1, and no IPv6 name servers?

TIA.
S

Use option 6:

/etc/config/dhcp

list dhcp_option '6,1.1.1.1'

Just add it in the Interface section you want it to use for, you can use tagging to set it for individual clients e.g.:

config tag 'tag1'
	list dhcp_option '6,1.1.1.1'

config host
	option name 'client1'
	option mac '00:21:63:75:aa:17'
	option ip '10.11.12.14'
	option tag 'tag1'

config host
	option name 'client2'
	option mac '01:22:64:76:bb:18'
	option ip '10.11.12.15'
	option tag 'tag1'
2 Likes

Can I add it for a specifically assigned address?

e.g like this:

config host
option name 'osmio4kplus'
option dns '1'
option mac '2C:CC:CC:CC:CC:CC'
option ip '192.168.1.191'
option list dhcp_option '6,1.1.1.1'

And will this ensure that no IPv6 DNS name server gets assigned? Unless of course something like 2606:4700:4700::1111 will work.

Although would not this command add DNS IPv4 for everything:
uci add_list dhcp.lan.dhcp_option="6,1.1.1.1"

Or could I use this to add multiple name servers?
uci add_list dhcp.lan.dhcp_option="6,1.1.1.1,2606:4700:4700::1111,8.8.8.8"

Didn't look at the examples, did you?

It'll assign what you tell it to assign.

Clients honoring them, is a completely different topic though.

1 Like

Didn't look at the examples, did you?

Yes, but reading does not mean I understood it. All I see is that I can break my DHCP by not decyphering the examples correctly.

e.g Why do I need to add vlan tagging to this?
Use the tag classifier to create a tagged group

Although, I think I just do:

uci add_list dhcp.lan.dhcp_option="6,1.1.1.1,2606:4700:4700::1111" && uci commit dhcp && service dnsmasq restart

I put this in the file:

config tag 'dns1111'
	list dhcp_option '6,1.1.1.1,2606:4700:4700::1111'
....
config host
	option name 'osmio4kplus'
	option dns '1'
	option mac 'xx:xx:xx:xx:xx:xx'
	option ip '192.168.1.191'
	option tag 'dns1111'

Does this correct?

I think you have to use the tagging as described and it has nothing to do with vlans.
you can use multiple DNS servers, I use:

config tag 'tag1'
	list dhcp_option '6,8.8.8.8,8.8.4.4'

But you cannot mix IPv6, the syntax for IPv6 is different.
For DNSMasq it should be something like:
dhcp-option=option6:dns-server, [2606:4700:4700::1111]

But I do not know how to translate this in uci

1 Like

Thanks.

therefore I can have a separate line in /etc/config/dhcp for one of my posts with a line for specifying IPv6, and another line specifying IPv4.

"But you need a device with large flash to run dnsmasq-full, as far as I understand this is the main reason we don’t have the full dnsmasq package included as default."

What makes no sense is that openwrt is pushing some Ipv6 to my devices which is already nameserver fd82:61c8:2ad1::1.

Odhpcd is the OpenWrt-specific IPv6 addressing server for the Lan side. To my knowledge, it handles both DHCPv6 and slaac.

So I think you cannot do this with DNSMasq.

You can turn off the handout of IPv6 DNS address and you might not need it as DNS servers handout both IPv4 and IPv6 addresses if queried by IPv4.

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

1 Like

Done :slight_smile:

Luci -> Network -> Interfaces -> lan / Edit -> Advanced Settings -> DHCP-Options : 6,1.1.1.1

and

Luci -> Network -> Interfaces -> lan / Edit -> IPv6 Settings -> Announced IPv6 DNS servers : 2606:4700:4700::1111

Thank-you everybody for your help, ideas, and patience.

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