Network setup
My network uses a Mikrotik hAP ax3 as a router connected to my ISP modem (192.168.1.1). A local DNS server is running with an assigned IP-address of 10.0.0.10.
The router serves as a DHCP server for all clients with an IP-pool in the range of 10.0.0.100 to 10.0.0.254 and a DNS server of 10.0.0.1 (router address).
The Mikrotik DNS server is configured as the ISP modem address, making use of the ISP provided DNS servers by default.
Problem description
I want to make sure all DNS traffic is redirected to the local DNS server using a firewall NAT rule for TCP/UDP traffic on port 53.
I have configured the following firewall NAT rules:
Code: Select all
add action=dst-nat chain=dstnat comment="DNS dst-nat UDP" disabled=no \
dst-port=53 in-interface=bridge-LAN protocol=udp src-address=!10.0.0.10 \
to-addresses=10.0.0.10 to-ports=53
add action=dst-nat chain=dstnat comment="DNS dst-nat TCP" disabled=no \
dst-port=53 in-interface=bridge-LAN protocol=tcp src-address=!10.0.0.10 \
to-addresses=10.0.0.10 to-ports=53
The following behaviour is observed:
- When configuring the DHCP server to provide the DNS address of the Mikrotik router (10.0.0.1), everything works as expected.
- When configuring the DHCP server to provide the DNS address of my local DNS server (10.0.0.10), everything works as expected as well.
- However, if I configure the DHCP server to provide the DNS address of the router and enable the NAT rules then DNS queries are not resolved anymore.
Any help would be much appreciated.
Configuration
RouterOS version is 7.14.2 with RouterBOARD version 7.14.2 using the following configuration:
Code: Select all
# 2024-04-14 10:37:19 by RouterOS 7.14.2
# software id = 2IEW-LXGZ
#
# model = C53UiG+5HPaxD2HPaxD
# serial number = HEQ09CE89JG
/interface bridge
add admin-mac=78:9A:18:05:DA:B5 auto-mac=no name=bridge-LAN port-cost-mode=\
short
/interface ethernet
set [ find default-name=ether1 ] name=ether1-LAN1
set [ find default-name=ether2 ] name=ether2-LAN2
set [ find default-name=ether3 ] name=ether3-LAN3
set [ find default-name=ether4 ] name=ether4-LAN4
set [ find default-name=ether5 ] name=ether5-WAN
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wifi channel
add band=2ghz-ax disabled=no name=channel-2.4GHz skip-dfs-channels=10min-cac
add band=5ghz-ax disabled=no name=channel-5GHz skip-dfs-channels=10min-cac
/interface wifi security
add authentication-types=wpa2-psk,wpa3-psk disabled=no name=sec-home
/interface wifi configuration
add country=Netherlands disabled=no mode=ap name=cfg-home security=sec-home \
ssid=wifi-test
/interface wifi
set [ find default-name=wifi2 ] channel=channel-2.4GHz configuration=cfg-home \
configuration.mode=ap disabled=no name="wifi1-WLAN1 (2.4GHz)" \
security.authentication-types=wpa2-psk,wpa3-psk
set [ find default-name=wifi1 ] channel=channel-5GHz configuration=cfg-home \
configuration.mode=ap disabled=no name="wifi2-WLAN2 (5GHz)" \
security.authentication-types=wpa2-psk,wpa3-psk
/ip pool
add name=dhcp-pool ranges=10.0.0.100-10.0.0.254
/ip dhcp-server
add address-pool=dhcp-pool interface=bridge-LAN lease-time=10m name=\
dhcp-server
/ip smb users
set [ find default=yes ] disabled=yes
/interface bridge port
add bridge=bridge-LAN interface=ether1-LAN1 internal-path-cost=10 path-cost=\
10
add bridge=bridge-LAN interface=ether2-LAN2 internal-path-cost=10 path-cost=\
10
add bridge=bridge-LAN interface=ether3-LAN3 internal-path-cost=10 path-cost=\
10
add bridge=bridge-LAN interface=ether4-LAN4 internal-path-cost=10 path-cost=\
10
add bridge=bridge-LAN interface="wifi2-WLAN2 (5GHz)" internal-path-cost=10 \
path-cost=10
add bridge=bridge-LAN interface="wifi1-WLAN1 (2.4GHz)" internal-path-cost=10 \
path-cost=10
/ip firewall connection tracking
set udp-timeout=10s
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface detect-internet
set detect-interface-list=WAN
/interface list member
add interface=bridge-LAN list=LAN
add interface=ether5-WAN list=WAN
/ip address
add address=10.0.0.1/24 comment=defconf interface=bridge-LAN network=10.0.0.0
/ip dhcp-client
add interface=ether5-WAN
/ip dhcp-server lease
add address=10.0.0.10 comment="Static IP-address for DNS server" mac-address=\
B8:27:EB:4F:FF:D0 server=dhcp-server
/ip dhcp-server network
add address=10.0.0.0/24 dns-server=10.0.0.1 gateway=10.0.0.1
#add address=10.0.0.0/24 dns-server=10.0.0.10 gateway=10.0.0.1
/ip dns
set allow-remote-requests=yes
/ip firewall filter
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
"defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
connection-state=established,related hw-offload=yes
add action=accept chain=forward comment=\
"defconf: accept established,related, untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid
add action=drop chain=forward comment=\
"defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
connection-state=new in-interface-list=WAN
/ip firewall nat
add action=masquerade chain=srcnat ipsec-policy=out,none out-interface-list=\
WAN
add action=dst-nat chain=dstnat comment="DNS dst-nat UDP" disabled=no \
dst-port=53 in-interface=bridge-LAN protocol=udp src-address=!10.0.0.10 \
to-addresses=10.0.0.10 to-ports=53
add action=dst-nat chain=dstnat comment="DNS dst-nat TCP" disabled=no \
dst-port=53 in-interface=bridge-LAN protocol=tcp src-address=!10.0.0.10 \
to-addresses=10.0.0.10 to-ports=53
/ip service
set telnet disabled=yes
set ftp disabled=yes
set ssh disabled=yes
set api disabled=yes
set api-ssl disabled=yes
/ip smb shares
set [ find default=yes ] directory=/pub
/ipv6 firewall address-list
add address=::/128 comment="defconf: unspecified address" list=bad_ipv6
add address=::1/128 comment="defconf: lo" list=bad_ipv6
add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6
add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6
add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6
add address=100::/64 comment="defconf: discard only " list=bad_ipv6
add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6
add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6
add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6
/ipv6 firewall filter
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=input comment="defconf: accept UDP traceroute" port=\
33434-33534 protocol=udp
add action=accept chain=input comment=\
"defconf: accept DHCPv6-Client prefix delegation." dst-port=546 protocol=\
udp src-address=fe80::/10
add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 \
protocol=udp
add action=accept chain=input comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=input comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=input comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
add action=accept chain=forward comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid
add action=drop chain=forward comment=\
"defconf: drop packets with bad src ipv6" src-address-list=bad_ipv6
add action=drop chain=forward comment=\
"defconf: drop packets with bad dst ipv6" dst-address-list=bad_ipv6
add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" \
hop-limit=equal:1 protocol=icmpv6
add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=forward comment="defconf: accept HIP" protocol=139
add action=accept chain=forward comment="defconf: accept IKE" dst-port=\
500,4500 protocol=udp
add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=forward comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=forward comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
/system clock
set time-zone-name=Europe/Amsterdam
/system identity
set name=router
/system note
set show-at-login=no
/system ntp client
set enabled=yes
/system ntp client servers
add address=0.nl.pool.ntp.org
add address=1.nl.pool.ntp.org
add address=2.nl.pool.ntp.org
add address=3.nl.pool.ntp.org
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN