Configure host-specific DNS server over DHCP (option 6)

Hello.

I need to configure a specific DNS server for a few of the hosts on my network.
In /etc/config/dhcp I have put

config host option name 'Roku_Bedroom' option dns '1' option mac 'AC:AE:19:AD:2A:5F' option ip '10.0.0.232' list dhcp_option '6,**10.10.10.1**' option force '1'

I have restarted the dhcp service and ever rebooted the entire router. Yet every time I get a lease, I still get the default DNS server for the subnet which is 10.0.0.1

root@wrt:~# tcpdump -vnes0 -i br-lan port 67 or port 68

18:17:01.407616 ac:ae:19:ad:2a:5f > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 590: (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 576)
    0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from ac:ae:19:ad:2a:5f, length 548, xid 0x76ce8e6c, Flags [none]
          Client-Ethernet-Address ac:ae:19:ad:2a:5f
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message Option 53, length 1: Request
            Requested-IP Option 50, length 4: 10.0.0.232
            Parameter-Request Option 55, length 5:
              Subnet-Mask, Default-Gateway, Domain-Name-Server, Domain-Name
              Hostname
            Hostname Option 12, length 7: "Bedroom"
18:17:01.503937 62:38:e0:c7:39:78 > ac:ae:19:ad:2a:5f, ethertype IPv4 (0x0800), length 353: (tos 0xc0, ttl 64, id 40337, offset 0, flags [none], proto UDP (17), length 339)
    10.0.0.1.67 > 10.0.0.232.68: BOOTP/DHCP, Reply, length 311, xid 0x76ce8e6c, Flags [none]
          Your-IP 10.0.0.232
          Server-IP 10.0.0.1
          Client-Ethernet-Address ac:ae:19:ad:2a:5f
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message Option 53, length 1: ACK
            Server-ID Option 54, length 4: 10.0.0.1
            Lease-Time Option 51, length 4: 43200
            RN Option 58, length 4: 21600
            RB Option 59, length 4: 37800
            Subnet-Mask Option 1, length 4: 255.255.255.0
            BR Option 28, length 4: 10.0.0.255
            Default-Gateway Option 3, length 4: 10.0.0.1
            Domain-Name-Server Option 6, length 4: 10.0.0.1
            Domain-Name Option 15, length 3: "lan"
            Hostname Option 12, length 12: "Roku_Bedroom"
^C
2 packets captured
6 packets received by filter
0 packets dropped by kernel

You can see the line Domain-Name-Server Option 6, length 4: 10.0.0.1

2 Likes

The example shows how to set certain hosts to use other DNS servers via DHCP Option No. 6.

3 Likes

Thanks for the suggestions. I will give it a try and report.

1 Like

Just wanted to report that things worked great.

config host
        option dns '1'
        option ip '10.0.0.200'
        option name 'LivingRoom'
        option mac 'FF:1A:6B:1A:9A:9B'
        option tag 'mountain_dns'
        option leasetime '300'

config tag 'mountain_dns'
        list dhcp_option '6,10.10.10.1'
3 Likes

What if I use another port, for example 5353?

What clients try to resolve DNS on a port other than 53? 5353 would be non-standard and require a customizable resolver on each and every client.

1 Like

My ISP is hijacking port 53, I'm currently using OpenDNS port 5353

config dnsmasq
	list server '208.67.222.222#5353'
	option noresolv '1'

Then you'll have to make sure your clients use your local DNS on port 53, and use whatever upstream port you want in your DNS.

Intercept all outgoing traffic on port 53.in the firewall, and redirect it to your local DNS, or directly to OpenDNS.

1 Like