Community discussions

MikroTik App
 
dmconde
just joined
Topic Author
Posts: 3
Joined: Tue Jun 20, 2023 11:21 am

Issues with DNS on router

Tue Mar 19, 2024 12:50 pm

Hi all,

I am quite new on Mikrotik but have done some basic setups already with no issues. Doing a new one I am getting a problem on router itself to resolve DNS (only required for updates honestly); disabling the rule to block traffic from WAN ("defconf: drop all not coming from LAN") it works but, of course I don't want to remove it (have also tried to do !LAN instead of WAN but same result), Can you please help me? Here you can find my config:

# mar/19/2024 10:47:41 by RouterOS 6.49.13
# software id = **ELIDED**
#
# model = RB3011UiAS
/interface bridge
add name=bridge_LAN
/interface ethernet
set [ find default-name=ether1 ] name=ether1-WAN1
set [ find default-name=ether2 ] name=ether2-WAN2
set [ find default-name=ether3 ] disabled=yes
set [ find default-name=ether4 ] disabled=yes
set [ find default-name=ether5 ] disabled=yes
set [ find default-name=sfp1 ] disabled=yes
/interface vrrp
add interface=bridge_LAN name=VRRP
/interface list
add name=LAN
add name=WAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=dhcp_pool_LAN ranges=20.1.0.50-20.1.1.254
/ip dhcp-server
add address-pool=dhcp_pool_LAN disabled=no interface=VRRP name=dhcp_LAN
/queue simple
add disabled=yes dst=ether1-WAN1 max-limit=10M/10M name=LimitWAN1 target=""
/interface bridge port
add bridge=bridge_LAN interface=ether6
add bridge=bridge_LAN interface=ether7
add bridge=bridge_LAN interface=ether8
add bridge=bridge_LAN interface=ether9
add bridge=bridge_LAN interface=ether10
/ip neighbor discovery-settings
set discover-interface-list=!dynamic
/interface list member
add interface=bridge_LAN list=LAN
add interface=ether1-WAN1 list=WAN
add interface=ether2-WAN2 list=WAN
/ip address
add address=20.1.0.2/23 interface=bridge_LAN network=20.1.0.0
add address=20.1.0.1/23 interface=VRRP network=20.1.0.0
add address=10.10.2.250/24 interface=ether1-WAN1 network=10.10.2.0
add address=10.10.1.250/24 interface=ether2-WAN2 network=10.10.1.0
/ip cloud
set ddns-enabled=yes
/ip dhcp-client
add add-default-route=no interface=ether1-WAN1 use-peer-dns=no
add add-default-route=no disabled=no interface=ether2-WAN2
/ip dhcp-server network
add address=20.1.0.0/23 dns-server=8.8.8.8,1.1.1.1 gateway=20.1.0.1
/ip dns
set servers=8.8.8.8,1.1.1.1
/ip firewall filter
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=drop chain=input comment="defconf: drop all not coming from LAN" \
    in-interface-list=WAN
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 out-interface=ether1-WAN1
add action=masquerade chain=srcnat out-interface=ether2-WAN2
/ip route
add check-gateway=ping distance=1 gateway=1.1.1.1 target-scope=32
add check-gateway=ping distance=2 gateway=8.8.8.8 target-scope=32
add check-gateway=ping distance=4 gateway=10.10.1.1
add distance=1 dst-address=1.1.1.1/32 gateway=10.10.2.1 target-scope=31
add distance=1 dst-address=8.8.8.8/32 gateway=10.10.2.1 target-scope=31
/system clock
set time-zone-name=Europe/London

Thanks in advance
Last edited by tangent on Tue Mar 19, 2024 1:11 pm, edited 1 time in total.
Reason: Elided PII; wrapped config in code block
 
dmconde
just joined
Topic Author
Posts: 3
Joined: Tue Jun 20, 2023 11:21 am

Re: Issues with DNS on router

Tue Mar 19, 2024 1:00 pm

Forgot to mention I have no issues to ping 8.8.8.8 using IP address instead of DNS name
 
CGGXANNX
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Thu Dec 21, 2023 6:45 pm

Re: Issues with DNS on router

Tue Mar 19, 2024 8:37 pm

The order of these two lines should be switched:

add action=drop chain=input comment="defconf: drop all not coming from LAN" \
    in-interface-list=WAN
add action=accept chain=forward comment=\
    "defconf: accept established,related, untracked" connection-state=\
    established,related,untracked
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19395
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Issues with DNS on router

Tue Mar 19, 2024 9:22 pm

Weird setup?
I see two WANs but are there any users or devices behind the router??
More weirdly trying to create a third WAN via VRF......... as noted I have no clue of the requirements for traffic flow here.
 
tangent
Forum Guru
Forum Guru
Posts: 1404
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: Issues with DNS on router

Wed Mar 20, 2024 7:08 am

The order of these two lines should be switched

No. Ordering is immaterial for rules in different chains.
 
CGGXANNX
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Thu Dec 21, 2023 6:45 pm

Re: Issues with DNS on router  [SOLVED]

Wed Mar 20, 2024 8:06 am

No. Ordering is immaterial for rules in different chains.
Oh yeah I misread the chain value, that's because I've already seen that a

add action=accept chain=input comment="defconf: accept established,related,untracked" \
     connection-state=established,related,untracked
line was missing in front of the
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
    in-interface-list=WAN

one and thought that the line that followed was that line. To OP: you are missing the "accept established,related,untracked" rule above for the chain input that should be placed in front of the "drop all" rule. Currently the router can send packet out to WAN but there are no rules to accept the answer packet (except for ICMP, that's why ping with IP address still works). Adding the line

add action=accept chain=input comment="defconf: accept established,related,untracked" \
     connection-state=established,related,untracked

will make sure that answer packets are allowed in.
 
tangent
Forum Guru
Forum Guru
Posts: 1404
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: Issues with DNS on router

Wed Mar 20, 2024 8:57 am

Yes, this now I believe. :)

@dmconde, you might want to read my guide on the default configuration. It was that way on purpose. Dropping that rule was not a good idea.
 
dmconde
just joined
Topic Author
Posts: 3
Joined: Tue Jun 20, 2023 11:21 am

Re: Issues with DNS on router

Wed Mar 20, 2024 9:20 am

thanks both! I actually created manually the firewall rules so didn't delete it :?

This is now working and, @tangent, had read now your guide and love it!!!

Who is online

Users browsing this forum: 4l4R1, JR2 and 13 guests