- Hahatay Network/
- β Technical Documentation/
- OpenWrt: Force Routers in the Network use a Local DNS Server/
OpenWrt: Force Routers in the Network use a Local DNS Server
·2 mins
Table of Contents
Note: This wiki page is very inspired on this oldish OpenWrt Forum post.
Long story short, we would like all the traffic from the community network to use our local DNS server and I would like to stop any clients from overriding the DNS with a custom one like Google’s (8.8.8.8).
Set Up WAN #
- Go to
Network
>Interfaces
>WAN
. - Click
Edit
. - Select the
Advanced Settings
tab and uncheckUse DNS servers advertised by peer
. - In the box below, enter the Local DNS Servers
192.168.10.4
and192.168.10.5
. - Click the
Save
button.
Set Up LAN #
- Go to
Network
>Interfaces
>LAN
- Under
DHCP Server
, go toAdvanced Options
and setDHCP-Options
to6,192.168.10.4,192.168.10.5
.- This advertises different DNS servers to clients. This is what the DHCP server will advertise as NameServer to the hosts (clients). If you don’t use it, the router itself will be advertised and will cache and forward the queries to the upstream NameServers.
- Click the
Save
button.
Set Up DHCP & DNS #
- Go to
Network
>DHCP and DNS
. - Under
General Settings
select theResolv and Hosts Files
tab ensure theIgnore resolve file
is unchecked. - Click the
Save
button.
Set Up Firewall #
- Go to
Network
>Firewall
- Under the
Port Forwards
tab, clickAdd
and enterForce DNS
underNew port forward
section - Set the
Protocol to TCP+UDP
- Set
Source zone
toWAN
** - Set
External port
to53
- Set
Destination zone
tolan
** - Set
Internal port
to53
- Click the
Add
button - Once it’s added to the list open it back up by clicking the
Edit
button - Change the
Source zone
fromwan
tolan
- Click the ‘Save & Apply’ button
- ****** If you’re unable to set the exact zones simply select anything as you can change it in step 9
The firewall rule should look like the following:
Afterwards, save and apply all the changes. Finally, reboot the router by heading to System
> Reboot