🥅 Get OpenWRT to serve a different DNS server

Here is how you can configure OpenWRT / dnsmasq to serve a specific DNS server to DHCP clients on your network.

By default, DHCP clients with OpenWRT / dnsmasq get the router IP (ie. IP of the OpenWRT router) as their DNS server. But what if you want your network devices to use a different DNS server?

Here is how you can do it:

config dhcp 'lan'
   option interface 'lan'
   list dhcp_option '6,10.4.2.2'

The list dhcp_option '6,10.4.2.2 is the critical configuration. DHCP option 6 is the how a DNS resolver is served to the DHCP clients.


Many other types of information can be served via DHCP.

$ dnsmasq --help dhcp
Known DHCP options:
  1 netmask
  2 time-offset
  3 router
  6 dns-server
  7 log-server
  9 lpr-server
 13 boot-file-size
 15 domain-name
 16 swap-server
 17 root-path
 18 extension-path
 19 ip-forward-enable
 20 non-local-source-routing
 21 policy-filter
 22 max-datagram-reassembly
 23 default-ttl
 26 mtu
 27 all-subnets-local
 31 router-discovery
 32 router-solicitation
 33 static-route
 34 trailer-encapsulation
 35 arp-timeout
 36 ethernet-encap
 37 tcp-ttl
 38 tcp-keepalive
 40 nis-domain
 41 nis-server
 42 ntp-server
 44 netbios-ns
 45 netbios-dd
 46 netbios-nodetype
 47 netbios-scope
 48 x-windows-fs
 49 x-windows-dm
 58 T1
 59 T2
 60 vendor-class
 64 nis+-domain
 65 nis+-server
 66 tftp-server
 67 bootfile-name
 68 mobile-ip-home
 69 smtp-server
 70 pop3-server
 71 nntp-server
 74 irc-server
 77 user-class
 80 rapid-commit
 93 client-arch
 94 client-interface-id
 97 client-machine-id
100 posix-timezone
101 tzdb-timezone
108 ipv6-only
119 domain-search
120 sip-server
121 classless-static-route
125 vendor-id-encap
150 tftp-server-address
255 server-ip-address