dst-nat not getting to work

Hi,

For some reason I don’t get dst-nat not working. For sure there will be 1 little change I have to make, but I don’t see it. I hope one of you see it.

I tried a lot of things. I’m debugging sinds friday.

/ip firewall nat export

add action=masquerade chain=srcnat out-interface=pppoe-out1
add action=dst-nat chain=dst-nat in-interface=pppoe-out1 log=yes log-prefix=dstnat: port=4000 protocol=tcp to-addresses=10.175.78.2 to-ports=22

/ip firewall filter export

add action=accept chain=input dst-port=4000 log=yes log-prefix="input 4000:" protocol=tcp
add action=accept chain=forward dst-port=4000 in-interface=pppoe-out1 log=yes log-prefix="forward 4000:" protocol=tcp
add action=accept chain=input protocol=icmp
add action=accept chain=input comment="ROOT toegang" src-address=217.119.224.143
add action=accept chain=input port=2222 protocol=tcp 
add action=accept chain=input connection-state=established
add action=accept chain=input connection-state=related
add action=drop chain=input comment="Default drop" log-prefix=yes
add action=accept chain=forward connection-state=established
add action=accept chain=forward connection-state=related
add action=drop chain=forward disabled=yes dst-address=10.0.0.0/8 src-address=10.0.0.0/8 [disabled]

the address 10.175.78.2 is a address located on a switch with mgmt vlan 10.

Please tell me what I’m doing wrong.

The first thing I’ve learned to check when dst-nat fails is: Does the target device (10.175.78.2 in your case) have the router (where the forward rule is being applied) as its default gateway for internet?

If it doesn’t have the mikrotik as its default gateway, then you should change that if you can (or create a specific static route on the target host pointing to the connecting host via the mikrotik as its gateway), otherwise your only option is srcnat (hairpin or masquerade) AFAIK

Basically, the traffic returning from the target device needs to route back through the same router doing the dst-nat forwarding, otherwise any other configured gateways are likely to mark the packets as invalid & drop them on the spot.

The target device use already the router as its default gateway.

I see that the dst-nat rule not get hit.

If I do /ip firewall nat print stats" There is no traffic that hits the dst-nat rule.

Also a torch on the lan side shows no traffic.

If no traffic even hits the dst-nat rule, then the problem is likely firewall-related or that your ISP is blocking access to that port from on their side so the traffic never even reaches your main router. Make sure there are no other nat rules above this one, such as a DMZ rule which could be intercepting that traffic and not letting it pass-through to your dst-nat rule

Without seeing the full config its not a complete picture…
However there are some things that are concerning.

add action=accept chain=forward dst-port=4000 in-interface=pppoe-out1 log=yes log-prefix=“forward 4000:” protocol=tcp

The forward chain is not normally the place to make port forwarding rules, and thus this needs to either move to dstnat, or be removed entirely

The forward chain is missing a rule to permit port forwarding. (besides the fact that the rules are rather not well put together or complete)
add chain=forward action=accept connection-nat-state=dstnat


This is a rule begging for problems… first of all access to the router itself externally should ONLY be via VPN. Recommend deleting ASAP.
add action=accept chain=input comment=“ROOT toegang” src-address=217.119.224.143

The port forward is done in dst-nat chain. We are also the isp, so we know for sure that the traffic is not blocked.

Regarding the rule for accepting the dstnat traffic in filter. There is no blocking rule so than this is not needed? Mikrotik firewall accept by default right?

Here is the full config:

# apr/12/2022 15:32:42 by RouterOS 6.49.5
# software id = MJU5-S2UH
#
# model = 2011UiAS
# serial number = 444802BA1138
/interface bridge
add fast-forward=no mtu=1500 name=bridge1 protocol-mode=none
/interface ethernet
set [ find default-name=ether1 ] name=ether1-wan speed=100Mbps
set [ find default-name=ether2 ] name=ether2-sw01 speed=100Mbps
set [ find default-name=ether3 ] name=ether3-sw02 speed=100Mbps
set [ find default-name=ether4 ] speed=100Mbps
set [ find default-name=ether5 ] speed=100Mbps
/interface pppoe-client
add add-default-route=yes disabled=no interface=ether1-wan keepalive-timeout=\
    60 max-mru=1480 max-mtu=1480 name=pppoe-out1 password=##### user=#####
/interface vlan
add interface=bridge1 name="epacity printen" vlan-id=50
add interface=bridge1 name=mgmt vlan-id=10
add interface=bridge1 name=salto vlan-id=40
add interface=bridge1 name=ssid-### vlan-id=20
add interface=bridge1 name=ssid-###-guest vlan-id=30
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip ipsec proposal
set [ find default=yes ] enc-algorithms=3des
/ip pool
add name=dhcp_pool_mgmt ranges=10.175.78.100-10.175.78.150
add name=dhcp_pool_ssid-### ranges=10.176.78.10-10.180.78.250
add name=dhcp_pool_ssid-###-guest ranges=10.177.78.10-10.180.78.250
add name=dhcp_pool_werkplekken ranges=10.180.78.100-10.180.78.150
/ip dhcp-server
add address-pool=dhcp_pool_mgmt authoritative=after-2sec-delay disabled=no \
    interface=mgmt lease-time=3d name=dhcp-mgmt
add address-pool=dhcp_pool_ssid-### authoritative=after-2sec-delay disabled=\
    no interface=ssid-### lease-time=3d name=dhcp-ssid-###
add address-pool=dhcp_pool_ssid-###-guest authoritative=after-2sec-delay \
    disabled=no interface=ssid-###-guest lease-time=3d name=\
    dhcp-ssid-###-guest
add address-pool=dhcp_pool_werkplekken authoritative=after-2sec-delay \
    disabled=no interface=bridge1 lease-time=3d name=dhcp-werkplekken
/system logging action
set 0 memory-lines=100
set 1 disk-lines-per-file=100
/interface bridge port
add bridge=bridge1 hw=no interface=ether2-sw01
add bridge=bridge1 hw=no interface=ether3-sw02
add bridge=bridge1 hw=no interface=ether4
/ip address
add address=10.180.78.1/24 interface=ether2-sw01 network=10.180.78.0
add address=10.175.78.1/24 interface=mgmt network=10.175.78.0
add address=10.176.78.1/24 interface=ssid-### network=10.176.78.0
add address=10.177.78.1/24 interface=ssid-###-guest network=10.177.78.0
add address=10.179.78.1/24 interface=ether5 network=10.179.78.0
/ip dhcp-server network
add address=10.175.78.0/24 dns-server=8.8.8.8,8.8.4.4 gateway=10.175.78.1
add address=10.176.78.0/24 dns-server=8.8.8.8,8.8.4.4 gateway=10.176.78.1
add address=10.177.78.0/24 dns-server=8.8.8.8,8.8.4.4 gateway=10.177.78.1
add address=10.180.78.0/24 dns-server=8.8.8.8,8.8.4.4 gateway=10.180.78.1
/ip dns
set servers=8.8.8.8,8.8.4.4
/ip firewall address-list
add address=#### list=mgmt
add address=#### list=mgmt
/ip firewall filter
add action=accept chain=input dst-port=4000 log=yes log-prefix="input 4000:" \
    protocol=tcp
add action=accept chain=forward dst-port=4000 in-interface=pppoe-out1 log=yes \
    log-prefix="forward 4000:" protocol=tcp
add action=accept chain=input protocol=icmp
add action=accept chain=input comment="ROOT toegang" src-address-list=mgmt
add action=accept chain=input port=2222 protocol=tcp
add action=accept chain=input connection-state=established
add action=accept chain=input connection-state=related
add action=drop chain=input comment="Default drop" log-prefix=yes
add action=accept chain=forward connection-state=established
add action=accept chain=forward connection-state=related
add action=drop chain=forward disabled=yes dst-address=10.0.0.0/8 \
    src-address=10.0.0.0/8
/ip firewall nat
add action=masquerade chain=srcnat out-interface=pppoe-out1
add action=dst-nat chain=dst-nat in-interface=pppoe-out1 log=yes log-prefix=\
    dstnat: port=4000 protocol=tcp to-addresses=10.175.78.2 to-ports=22
/ip proxy
set cache-path=web-proxy1 parent-proxy=0.0.0.0
/ip service
set ssh address=####
/system clock
set time-zone-autodetect=no time-zone-name=Europe/Amsterdam

Yes you are right it should be permitted as the Default Concept for beginners is to allow ALL unless blocked.
Anyone with a minute of experience quickly changes this to BLOCK ALL unless allowed.
Being an ISP one would think you would be of the ILK to block ALL…

(1) Discrepancy: You have five vlans and four pools… ( which is werkplekken SALTO or EAPICTY PRINTEN ?? )

(2) Discrepancy: Which is not like the others!
/ip dhcp-server
add address-pool=dhcp_pool_mgmt authoritative=after-2sec-delay disabled=no
interface=mgmt lease-time=3d name=dhcp-mgmt
add address-pool=dhcp_pool_ssid-### authoritative=after-2sec-delay disabled=
no interface=ssid-### lease-time=3d name=dhcp-ssid-###
add address-pool=dhcp_pool_ssid-###-guest authoritative=after-2sec-delay
disabled=no interface=ssid-###-guest lease-time=3d name=
dhcp-ssid-###-guest
add address-pool=dhcp_pool_werkplekken authoritative=after-2sec-delay
disabled=no interface=bridge1 lease-time=3d name=dhcp-werkplekken

(3) Discrepancy: What is not right?
/ip address
add address=10.180.78.1/24 interface=ether2-sw01 network=10.180.78.0
add address=10.175.78.1/24 interface=mgmt network=10.175.78.0
add address=10.176.78.1/24 interface=ssid-### network=10.176.78.0
add address=10.177.78.1/24 interface=ssid-###-guest network=10.177.78.0
add address=10.179.78.1/24 interface=ether5 network=10.179.78.0

(4) What is right about IP adddresses… can you tell ???
Yes, finally we see that perhaps there are 5 subnets and thus matches back to the initial 5 VLANS :slight_smile:))))

(5) I am not an ISP so I have no clue on WTF you are doing with port 4000, but this seems very WRONG to me! So can you please explain the purpose of these three rules and how they will function??
/ip firewall filter
add action=accept chain=input dst-port=4000 log=yes log-prefix=“input 4000:”
protocol=tcp
add action=accept chain=forward dst-port=4000 in-interface=pppoe-out1 log=yes
log-prefix=“forward 4000:” protocol=tcp
add action=dst-nat chain=dst-nat in-interface=pppoe-out1 log=yes log-prefix=
dstnat: port=4000 protocol=tcp to-addresses=10.175.78.2 to-ports=22

(6) Should one assume these are LAN IPs with access to the router?? (if so at least state in-interface-list=LAN
add action=accept chain=input comment=“ROOT toegang” src-address-list=mgmt

(7) Missing dst-
add action=dst-nat chain=dst-nat in-interface=pppoe-out1 log=yes log-prefix=
dstnat: **???**port=4000 protocol=tcp to-addresses=10.175.78.2 to-ports=22

If you say that you’re ISP, I guess I can’t seriously ask if you know what is public address and if you’re sure that you have it. But not having it would be one explanation for no hits on dstnat rule. Another could be if you’d be testing this from inside, it wouldn’t work because of in-interface=pppoe-out1.

@anav: About (5), dstnat is incomplete (it’s missing dst-port=4000) and the two filter rules are nonsense/wrong (input for port 4000 is useless, because dstnat won’t let if go there, and forward for port 4000 is wrong because at that point it will have destination port 22).

You failed to read point 7 but YES!! I was hoping for the OP to discover that his rules were nonsense, you know light bulb on moment, concrete learning achieved/assimilated. …sigh…

This is a lab setup. A lot of config isn’t right. One vlan should not exist anymore. That is replaced with a dedicated port ether 5. There are 5 ip networks. Only 4 dhcp-servers because one network is static assignments only.

For the dst-nat I have tried a lot of things in the firewall because I was sure it was something that is blocked in the firewall. That’s the reason why there are some strange firewall rules. It was just for learning. I know some rules are nonsense.

I know for sure it has a public ip adress. It gets an public address from our bras via pppoe.

Then double-check if there really isn’t any filtering on the way. If PPPoE gets public address and you connect to it from internet (or from your ISP network, just from router’s WAN side), then dstnat rule must get some hits. Even if the whole thing didn’t work for another reason, this is the first step that must happen.

Worked for me! Thanks! :slight_smile: