Community discussions

MikroTik App
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 6:08 pm

Hello to all Mikrotik enthusiasts,

Merry Christmas and Happy New Year!

I recently purchased a new Mikrotik L009UiGS-RM. Using the default configuration, I’m trying to open port 443 (and other ports) on it, but for some reason—unknown to me—I haven’t been able to.

The ether1 interface has a WAN connection with the public IP address xxx.xx.xx.123. There is another public IP (xxx.xx.xx.122) on the same interface, but you can ignore it for now.

the ip 192.168.88.200 represent my server.

So please advise.
here is my configuration:
[b]# 2024-12-28 18:54:30 by RouterOS 7.12.2
# software id = 
#
# model = L009UiGS
# serial number = 

/interface bridge
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.190
/ip dhcp-server
add address-pool=default-dhcp interface=bridge lease-time=10m name=defconf
/port
set 0 name=serial0
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=ether6
add bridge=bridge comment=defconf interface=ether7
add bridge=bridge comment=defconf interface=ether8

/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN

/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=\
    192.168.88.0

add address=xxx.xx.xx.123/24 interface=ether1 network=xxx.xx.xx.0
add address=xxx.xx.xx.122/24 interface=ether1 network=xxx.xx.xx.0

/ip dhcp-client
add comment=defconf interface=ether1

/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf dns-server=192.168.88.1 gateway=\
    192.168.88.1

/ip dns
set allow-remote-requests=yes servers=1.1.1.1
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan
/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=src-nat chain=srcnat comment="defconf: masquerade" ipsec-policy=\
    out,none out-interface-list=WAN src-address=192.168.88.0/24 to-addresses=\
    xxx.xx.xx.123
add action=src-nat chain=srcnat comment="defconf: masquerade" ipsec-policy=\
    out,none out-interface-list=WAN src-address=192.168.88.0/24 to-addresses=\
    xxx.xx.xx.122

add action=dst-nat chain=dstnat dst-address=xxx.xx.xx.123 dst-port=443 \
    protocol=tcp to-addresses=192.168.88.200 to-ports=443
add action=dst-nat chain=dstnat dst-address=xxx.xx.xx.123 dst-port=443 \
    protocol=udp to-addresses=192.168.88.200 to-ports=443
add action=dst-nat chain=dstnat dst-address=xxx.xx.xx.123 dst-port=3306 \
    protocol=tcp to-addresses=192.168.88.200 to-ports=3306
add action=dst-nat chain=dstnat dst-address=xxx.xx.xx.123 dst-port=115 \
    protocol=tcp to-addresses=192.168.88.200 to-ports=115
add action=dst-nat chain=dstnat dst-address=xxx.xx.xx.123 dst-port=3389 \
    protocol=tcp to-addresses=192.168.88.200 to-ports=3389
add action=dst-nat chain=dstnat dst-address=xxx.xx.xx.123 dst-port=22 \
    protocol=tcp to-addresses=192.168.88.200 to-ports=22
add action=dst-nat chain=dstnat dst-address=xxx.xx.xx.123 dst-port=80 \
    protocol=tcp to-addresses=192.168.88.200 to-ports=80

/ip route
add disabled=no dst-address=0.0.0.0/0 gateway=xxx.xx.xx.1 routing-table=main \
    suppress-hw-offload=no

/ip service
set telnet disabled=yes
set ftp disabled=yes
set www disabled=yes
set ssh disabled=yes
set api disabled=yes
set api-ssl disabled=yes

/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=
/system note
set show-at-login=no
/system routerboard settings
set enter-setup-on=delete-key
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN[/b]
Last edited by Techsystem on Sat Dec 28, 2024 6:40 pm, edited 1 time in total.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11228
Joined: Mon Dec 04, 2017 9:19 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 6:22 pm

There is nothing unusual in your configuration, so since it "doesn't work", my first question is how do you test it. If you try to connect to x.x.x.123 from a device in 192.168.88.0/24, you would have to set up a "hairpin NAT" to make it work when the server is also in 192.168.88.0/24. But there are better approaches if you need clients in LAN to access a server in LAN via the public address, and if you only need it for testing, it is better to test it from the internet, i.e. the same way it will work in production.

Also, you only need to set to-ports in NAT rules if you want them to change the ports - in your case, it is not necessary. But nor is it harmful.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 6:31 pm

There is nothing unusual in your configuration, so since it "doesn't work", my first question is how do you test it. If you try to connect to x.x.x.123 from a device in 192.168.88.0/24, you would have to set up a "hairpin NAT" to make it work when the server is also in 192.168.88.0/24. But there are better approaches if you need clients in LAN to access a server in LAN via the public address, and if you only need it for testing, it is better to test it from the internet, i.e. the same way it will work in production.

Also, you only need to set to-ports in NAT rules if you want them to change the ports - in your case, it is not necessary. But nor is it harmful.
Hello Sindy.
1-I am testing from outside, but that doesn't matter—it should work from both sides. I have the exact same setup with my CCR2004, and I can see the port is open from both outside and inside.
2-No, I want to open this port to make my server accessible from outside my LAN.
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 3030
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 6:35 pm

@Techsystem: could you be so kind and edit your post to apply proper tags for code?
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11228
Joined: Mon Dec 04, 2017 9:19 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 6:41 pm

1-I am testing from outside, but that doesn't matter—it should work from both sides. I have the exact same setup with my CCR2004, and I can see the port is open from both outside and inside.
Open a command line window, make it as wide as your screen allows, run /tool sniffer quick port=3389 in it, and try establishing a RDP connection from the test client to the server. It should show you whether the connection attempt arrives at all and if yes, what happens next.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 6:42 pm

@Techsystem: could you be so kind and edit your post to apply proper tags for code?
Hey BartoszP, You mean like this above..?
recheck the post.
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 3030
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 6:44 pm

Perfetto as would Italian say. :)
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 6:59 pm

1-I am testing from outside, but that doesn't matter—it should work from both sides. I have the exact same setup with my CCR2004, and I can see the port is open from both outside and inside.
Open a command line window, make it as wide as your screen allows, run /tool sniffer quick port=3389 in it, and try establishing a RDP connection from the test client to the server. It should show you whether the connection attempt arrives at all and if yes, what happens next.
Here is what I get when trying to establish a Remote Desktop connection to the server:

On my side, the connection keeps rendering, and in the end, I receive a "connection timeout" error.
You do not have the required permissions to view the files attached to this post.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11228
Joined: Mon Dec 04, 2017 9:19 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 8:10 pm

What does /ip arp print where address=192.168.88.200 show? The firewall rules are OK, there are no IPsec policies, no routing tables except main, no rules in raw... so unless there is a typo in the .123 address in the dst-nat rules, if the server at 192.168.88.200 can be pinged from the router itself, it looks like a bug.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 8:30 pm

What does /ip arp print where address=192.168.88.200 show? The firewall rules are OK, there are no IPsec policies, no routing tables except main, no rules in raw... so unless there is a typo in the .123 address in the dst-nat rules, if the server at 192.168.88.200 can be pinged from the router itself, it looks like a bug.
You do not have the required permissions to view the files attached to this post.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 8:31 pm

What does /ip arp print where address=192.168.88.200 show? The firewall rules are OK, there are no IPsec policies, no routing tables except main, no rules in raw... so unless there is a typo in the .123 address in the dst-nat rules, if the server at 192.168.88.200 can be pinged from the router itself, it looks like a bug.
You do not have the required permissions to view the files attached to this post.
 
User avatar
jvanhambelgium
Forum Guru
Forum Guru
Posts: 1119
Joined: Thu Jul 14, 2016 9:29 pm
Location: Belgium

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 8:37 pm

Is the target host a Windows machine ?
No host-firewall issues ?

If a Linux, can you do a quick "tcpdump" to see what actually ARRIVES there ?
If a Windows, perhaps quickly install "Wireshark" or something for a test.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11228
Joined: Mon Dec 04, 2017 9:19 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 8:48 pm

Have you ever modified the dst-nat rules or have you put them in exactly the way they look now?

In recent ROS 7 versions, there is a nasty bug with some configuration items - if you modify them, the changes do not make it from the "visible" configuration to the "running" one. In some cases, disabling and enabling that item helps, in other cases it apparently doesn't. I don't know since when the bug is there so 7.12.2 may or may not be affected.

In any case, please try the following:
/ip firewall nat add chain=dstnat in-interface=ether1 protocol=tcp dst-port=3389 action=dst-nat to-addresses=192.168.88.200 place-before=[find where dst-port~"3389"]
and then try testing while sniffing like in the first case again.
 
User avatar
Paternot
Forum Guru
Forum Guru
Posts: 1059
Joined: Thu Jun 02, 2016 4:01 am
Location: Niterói / Brazil

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 10:03 pm

Are You sure Your ISP isn't blocking the port? 443 is HTTPS - and ISPs love to block it on residential installations. Set the a firewall rule to log access to this port, and see if something is getting in.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11228
Joined: Mon Dec 04, 2017 9:19 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 10:13 pm

@Paternot, the first sniff result shows that the initial packet for port 3389 did arrive to ether1, so the ISP does not block it.

@Techsystem, @jvanhambelgium's suggestion made me realize I may have jumped to conclusions too quickly - for the bridge port via which the server at .88.200 is reachable, set hw on the corresponding /interface bridge port row to no and run the sniffer again. Sniffing on ports with hw=yes may not show some traffic.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 22089
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 11:02 pm

1. The first problem I see is that you have both
an IP address for WAN on ether1 AND a dhcp client on ether1.
It cannot be both!!!
If your certain about the IP address disable the dhcp client.

2 Suggest changing this default rule to three rules which are clearer as to the functionality and a bit more secure as well.
from:
add action=drop chain=forward comment=\
"defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
connection-state=new in-interface-list=WAN

TO:
add action=accept chain=forward comment="internet traffic" in-interface-list=LAN out-interface-list=WAN
add action=accept chain=forward comment="port forwarding" connection-nat-state=dstnat
add action=drop chain=forward comment="drop all else"


3. Masquerade rules are misleading in that the comments should be removed ( these are action sourcenat NOT masquerade )
I dont think you need source address of the lan either but probably no harm.

/ip firewall nat
add action=src-nat chain=srcnat comment="defconf: masquerade" ipsec-policy=\
out,none out-interface-list=WAN src-address=192.168.88.0/24 to-addresses=\
xxx.xx.xx.123
add action=src-nat chain=srcnat comment="defconf: masquerade" ipsec-policy=\
out,none out-interface-list=WAN src-address=192.168.88.0/24 to-addresses=\
xxx.xx.xx.122


4. Other than that, dont see anything.
 
wrkq
Frequent Visitor
Frequent Visitor
Posts: 71
Joined: Mon Jul 29, 2019 10:59 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sat Dec 28, 2024 11:27 pm

1. The first problem I see is that you have both
an IP address for WAN on ether1 AND a dhcp client on ether1.
It cannot be both!!!
Of course it can be both, but one need to /really/ know that's what they want.

Case in point, DOCSIS cable modems have the hard-coded-in-standard 192.168.100.1 IP for the management interface.
I have the modem configured in bridge mode, so it assigns me an upstream IP by DHCP and a gateway IP somewhere "up there" in ISP's network. It does not do any routing tasks.
And so, I have secondary static 192.168.100.2 IP configured on the very same WAN interface next to the DHCP client, so I can access the modem and the internet at the same time.
 
User avatar
Paternot
Forum Guru
Forum Guru
Posts: 1059
Joined: Thu Jun 02, 2016 4:01 am
Location: Niterói / Brazil

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 1:06 am

@Paternot, the first sniff result shows that the initial packet for port 3389 did arrive to ether1, so the ISP does not block it.
Port 3389. He was complaining about port 443, wasn't he? Here is quite common for ISPs to block ports below 1024. Don't know about his case though.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 5:00 am

Is the target host a Windows machine ?
No host-firewall issues ?

If a Linux, can you do a quick "tcpdump" to see what actually ARRIVES there ?
If a Windows, perhaps quickly install "Wireshark" or something for a test.
Linux..
I will when I get back to my office.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 5:02 am

Have you ever modified the dst-nat rules or have you put them in exactly the way they look now?

In recent ROS 7 versions, there is a nasty bug with some configuration items - if you modify them, the changes do not make it from the "visible" configuration to the "running" one. In some cases, disabling and enabling that item helps, in other cases it apparently doesn't. I don't know since when the bug is there so 7.12.2 may or may not be affected.

In any case, please try the following:
/ip firewall nat add chain=dstnat in-interface=ether1 protocol=tcp dst-port=3389 action=dst-nat to-addresses=192.168.88.200 place-before=[find where dst-port~"3389"]
and then try testing while sniffing like in the first case again.
I tried disabling and enabling all the items, but that doesn't work.
here is the result
You do not have the required permissions to view the files attached to this post.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 5:08 am

@Paternot, the first sniff result shows that the initial packet for port 3389 did arrive to ether1, so the ISP does not block it.

@Techsystem, @jvanhambelgium's suggestion made me realize I may have jumped to conclusions too quickly - for the bridge port via which the server at .88.200 is reachable, set hw on the corresponding /interface bridge port row to no and run the sniffer again. Sniffing on ports with hw=yes may not show some traffic.
here is the result after I set hw to off in the target port.
You do not have the required permissions to view the files attached to this post.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 5:26 am

1. The first problem I see is that you have both
an IP address for WAN on ether1 AND a dhcp client on ether1.
It cannot be both!!!
If your certain about the IP address disable the dhcp client.

2 Suggest changing this default rule to three rules which are clearer as to the functionality and a bit more secure as well.
from:
add action=drop chain=forward comment=\
"defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
connection-state=new in-interface-list=WAN

TO:
add action=accept chain=forward comment="internet traffic" in-interface-list=LAN out-interface-list=WAN
add action=accept chain=forward comment="port forwarding" connection-nat-state=dstnat
add action=drop chain=forward comment="drop all else"


3. Masquerade rules are misleading in that the comments should be removed ( these are action sourcenat NOT masquerade )
I dont think you need source address of the lan either but probably no harm.

/ip firewall nat
add action=src-nat chain=srcnat comment="defconf: masquerade" ipsec-policy=\
out,none out-interface-list=WAN src-address=192.168.88.0/24 to-addresses=\
xxx.xx.xx.123
add action=src-nat chain=srcnat comment="defconf: masquerade" ipsec-policy=\
out,none out-interface-list=WAN src-address=192.168.88.0/24 to-addresses=\
xxx.xx.xx.122


4. Other than that, dont see anything.
Hello anav.
1-I was testing a few things and later disabled the IP client.

2-I will change that.

3-The default configuration included a masquerade comment, so I changed the rule without changing the comment, in my situation, masquerade doesn’t work. Therefore, I need to use src-nat instead.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 5:28 am

@Paternot, the first sniff result shows that the initial packet for port 3389 did arrive to ether1, so the ISP does not block it.
Port 3389. He was complaining about port 443, wasn't he? Here is quite common for ISPs to block ports below 1024. Don't know about his case though.
I am trying to open ports 3389, 443, 3306, and others, but none of them are working until now.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 5:31 am

1. The first problem I see is that you have both
an IP address for WAN on ether1 AND a dhcp client on ether1.
It cannot be both!!!
Of course it can be both, but one need to /really/ know that's what they want.

Case in point, DOCSIS cable modems have the hard-coded-in-standard 192.168.100.1 IP for the management interface.
I have the modem configured in bridge mode, so it assigns me an upstream IP by DHCP and a gateway IP somewhere "up there" in ISP's network. It does not do any routing tasks.
And so, I have secondary static 192.168.100.2 IP configured on the very same WAN interface next to the DHCP client, so I can access the modem and the internet at the same time.
In my case, I am receiving the internet from the ONU.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 6:58 am

Something to mention: I noticed that the only port responding to the rule is port 22. When I disable the dst NAT rule, the port closes.
Port 80 is open with and without the rule.
Is it possible that something with the ONU unit is preventing the rule from working on the MikroTik?
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 10:41 am

After contacting my ISP, they explained that the problem is related to how my public IPs are assigned.

I have two internet subscriptions, each with two public IPs:

Subscription 1: xxx.xx.xx.64 and xxx.xx.xx.65
Subscription 2: xxx.xx.xx.122 and xxx.xx.xx.123
The issue is that both subscriptions are using the same gateway on the ISP's side. This shared gateway is causing routing and NAT conflicts, especially for destination NAT (dst-nat) rules on the second subscription.The ISP mentioned that they would change the public IP for me for the second subscription.

Thank you to everyone who shared their help in this thread.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11228
Joined: Mon Dec 04, 2017 9:19 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 10:45 am

here is the result after I set hw to off in the target port.
This sniffing result clearly shows that the port forwarding on Mikrotik works as expected and the issue is somewhere else.

Look at the packets with timestamps 13.3xx (from the 3rd packet from the top on the picture):
  1. a packet to ..123:3389 arrives in via ether1
  2. a packet to ..88.200:3389 is sent out via bridge-the-IP-interface, so the dst-nat worked
  3. the same packet is shown to leave the bridge-the-virtual-switch via ether2
  4. a response from the server (source address ..88.200:3389) arrives via ether2
  5. the same packet is shown to enter routing via bridge-the-IP-interface
  6. the same packet is sent out via ether1 after un-dst-nating the source address, i.e. from ..123:3389
As you haven't shown the complete rows, it is impossible to say whether the server rejects the incoming connection requests or whether the responses get lost on their way from the L009 to the external client, but the L009 does its job properly.

So I'd now try the same again and instead of snapshoting the graphical window, I'd stop the sniffer and run (within a few minutes, the buffer gets cleared afterwards) /tool sniffer packet print detail file=rdp-attempt, download the resulting file rdp-attempt.txt, use text substitution to replace the public address, and post the modified file here for further analysis.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 10:57 am

here is the result after I set hw to off in the target port.
This sniffing result clearly shows that the port forwarding on Mikrotik works as expected and the issue is somewhere else.

Look at the packets with timestamps 13.3xx (from the 3rd packet from the top on the picture):
  1. a packet to ..123:3389 arrives in via ether1
  2. a packet to ..88.200:3389 is sent out via bridge-the-IP-interface, so the dst-nat worked
  3. the same packet is shown to leave the bridge-the-virtual-switch via ether2
  4. a response from the server (source address ..88.200:3389) arrives via ether2
  5. the same packet is shown to enter routing via bridge-the-IP-interface
  6. the same packet is sent out via ether1 after un-dst-nating the source address, i.e. from ..123:3389
As you haven't shown the complete rows, it is impossible to say whether the server rejects the incoming connection requests or whether the responses get lost on their way from the L009 to the external client, but the L009 does its job properly.

So I'd now try the same again and instead of snapshoting the graphical window, I'd stop the sniffer and run (within a few minutes, the buffer gets cleared afterwards) /tool sniffer packet print detail file=rdp-attempt, download the resulting file rdp-attempt.txt, use text substitution to replace the public address, and post the modified file here for further analysis.
Thank you, Sindy. Your conclusion is correct, and the above solution approves that.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11228
Joined: Mon Dec 04, 2017 9:19 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 11:07 am

1. how comes that the fact that there are two other public addresses, probably attached to another WAN, was not visible from your configuration export? Did you remove some rows you've assumed not to be relevant?

2. the srcnat rules in your export that only differ from each other by the to-addresses parameter will not work the way you expect. The first (upper) one shadows the second (lower) one, so all connections initiated from the LAN side will be src-nated to ..123.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 1:26 pm

1. how comes that the fact that there are two other public addresses, probably attached to another WAN, was not visible from your configuration export? Did you remove some rows you've assumed not to be relevant?

2. the srcnat rules in your export that only differ from each other by the to-addresses parameter will not work the way you expect. The first (upper) one shadows the second (lower) one, so all connections initiated from the LAN side will be src-nated to ..123.

No, I didn’t remove anything. However, I have two separate network connections, each with its own MikroTik router, but both share the same gateway.

After my ISP changed the gateway and subnet, the issue persisted. I initially marked this as solved based on their feedback, but now it’s clear that it’s not resolved.

If I don’t have a service running on a specific port, is there a tool I can use to make the port active?

I downloaded FileZilla and set it to use port 443, which worked and opened the port. However, this approach didn’t work for other ports.

Do you know of a tool I can use to run a service on ports like 3389, 3306, 115, etc.?
You do not have the required permissions to view the files attached to this post.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11228
Joined: Mon Dec 04, 2017 9:19 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 1:58 pm

I'm not good in Windows, but I'd say you can make use of to-ports and use a single service you know to work alright on the server (e.g. SSH at TCP port 22) and use one dst-nat rule at a time to forward the individual "outer" ports to it, like
chain=dstnat in-interface=ether1 protocol=tcp dst-port=3389 action=dst-nat to-addresses=192.168.88.200 to-ports=22
Of course, you would have to use an SSH client to test and tell it to contact port 3389 at ...123.

Other than that, it was exactly the point of my question - if the other two public addresses in the same subnet were not attached to another interface of the same Mikrotik, it could not be the reason why it behaved like it did (and still does).

But maybe the server at 192.168.88.200 has multiple network interfaces and each is connected to another Mikrotik?
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 2:41 pm

I'm not good in Windows, but I'd say you can make use of to-ports and use a single service you know to work alright on the server (e.g. SSH at TCP port 22) and use one dst-nat rule at a time to forward the individual "outer" ports to it, like
chain=dstnat in-interface=ether1 protocol=tcp dst-port=3389 action=dst-nat to-addresses=192.168.88.200 to-ports=22
Of course, you would have to use an SSH client to test and tell it to contact port 3389 at ...123.

Other than that, it was exactly the point of my question - if the other two public addresses in the same subnet were not attached to another interface of the same Mikrotik, it could not be the reason why it behaved like it did (and still does).

But maybe the server at 192.168.88.200 has multiple network interfaces and each is connected to another Mikrotik?
Okay, in this case, I can see that all my ports are open, but is this the right way to open ports? I am concerned about ports 443, 3306, 115, and 22. I don't need the others, like port 3389 (which was just for testing). Now, if an external request comes to port 3306 and then redirected to port 22, is that okay?
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 13050
Joined: Thu Mar 03, 2016 10:23 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 2:49 pm

Okay, in this case, I can see that all my ports are open, but is this the right way to open ports?

If you want ports open, then this is the right way. If you're concerned about security, then don't open them. Or restrict access to those ports.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 22089
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 3:10 pm

One option: use source address list on dstnat rule to make ports appear closed on scans and of course limits access........ ( external wanips can be spoofed )
Second option: have users wireguard in to the router and then access servers
Third option: Future case when Mikrotik adds zerotrust cloudflare tunnel so that ALL MT folks, one day, can safely host servers free from attacks........ circa 2050 maybe.......
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11228
Joined: Mon Dec 04, 2017 9:19 pm

Re: dstnat doesn't work on L009UiGS-RM Router  [SOLVED]

Sun Dec 29, 2024 3:17 pm

is this the right way to open ports?
Of course it is not the right way to open ports, but it is the right way to analyze the issue you experience, and I've suggested it for the latter purpose.

You have got an issue somewhere on a complex network path between the client application and the server application; in these cases, the first step is to identify the particular part of the path which causes the problem. So by redirecting all the ports you want to use, one by one, to a known-good port (22) on the server using the Mikrotik, we have proven that all the way from the client via the internet to the Mikrotik, the connections to all those ports work alright, so the issue must be between the Mikrotik and the server application. Since the server did respond somehow to incoming packets to port 3389, chances are very high that the issue is in fact in the networking configuration of the server.

So on the Mikrotik, the target configuration is to redirect incoming traffic to the desired ports to the address of the server without changing the port, but before we get there, we have to find out why the server handles incoming connections to port 22 alright but struggles with the rest.

So we come back to my original question, how many network interfaces does the server have?
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 5:38 pm

is this the right way to open ports?
Of course it is not the right way to open ports, but it is the right way to analyze the issue you experience, and I've suggested it for the latter purpose.

You have got an issue somewhere on a complex network path between the client application and the server application; in these cases, the first step is to identify the particular part of the path which causes the problem. So by redirecting all the ports you want to use, one by one, to a known-good port (22) on the server using the Mikrotik, we have proven that all the way from the client via the internet to the Mikrotik, the connections to all those ports work alright, so the issue must be between the Mikrotik and the server application. Since the server did respond somehow to incoming packets to port 3389, chances are very high that the issue is in fact in the networking configuration of the server.

So on the Mikrotik, the target configuration is to redirect incoming traffic to the desired ports to the address of the server without changing the port, but before we get there, we have to find out why the server handles incoming connections to port 22 alright but struggles with the rest.

So we come back to my original question, how many network interfaces does the server have?
So far, so good. The server has four interfaces: the first one is connected directly to the ONU unit with a public IP, and the second is connected to the MikroTik with the IP address 192.168.88.200. The server is on my side, but the configuration and password are with the other party, who I believe is a professional. They asked me to open this port, so I assume they know how to configure the network interface for it.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 5:39 pm

One option: use source address list on dstnat rule to make ports appear closed on scans and of course limits access........ ( external wanips can be spoofed )
Second option: have users wireguard in to the router and then access servers
Third option: Future case when Mikrotik adds zerotrust cloudflare tunnel so that ALL MT folks, one day, can safely host servers free from attacks........ circa 2050 maybe.......
Nice mention!
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11228
Joined: Mon Dec 04, 2017 9:19 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 6:17 pm

The server has four interfaces: the first one is connected directly to the ONU unit with a public IP, and the second is connected to the MikroTik with the IP address 192.168.88.200.
(...)
I assume they know how to configure the network interface for it.
Assumption is good, knowledge is better. Professionals are just people who get paid for what they do, but we all make mistakes, regardless whether we currently wear the professional hat or the enthusiast one. There must be a deterministic reason why the server responds alright on port 22 but doesn't on the other ones.

A server that has multiple interfaces and at least one of them is behind a NAT must use some kind of policy routing (or VRF or network "namespace") to make sure to send responses to incoming requests from the same address to which those requests arrived and via the same interface through which they arrived, otherwise the responses will not get properly un-dst-nated and the client will not recognize them even if the ISP lets them get through despite their incorrect (from its perspective) source address. This part seems to be configured properly as the response did come back to the Mikrotik although its destination was a public address somewhere in the internet, so without policy routing, it would have taken the other route.

However, most server processes can be told to listen on all addresses of the server or only on specific ones. So if the incoming connections to port 3389 are actively rejected (sniffing as described earlier will clearly show whether it is the case), the reason may be that the process only listens on other address(es) than 192.168.88.200; in such a case (and several other ones), the TCP stack would reject the connection by sending a RST packet in response to the SYN one.
 
User avatar
Techsystem
Member
Member
Topic Author
Posts: 398
Joined: Tue Dec 21, 2021 5:12 am

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 8:08 pm

The server has four interfaces: the first one is connected directly to the ONU unit with a public IP, and the second is connected to the MikroTik with the IP address 192.168.88.200.
(...)
I assume they know how to configure the network interface for it.
Assumption is good, knowledge is better. Professionals are just people who get paid for what they do, but we all make mistakes, regardless whether we currently wear the professional hat or the enthusiast one. There must be a deterministic reason why the server responds alright on port 22 but doesn't on the other ones.

A server that has multiple interfaces and at least one of them is behind a NAT must use some kind of policy routing (or VRF or network "namespace") to make sure to send responses to incoming requests from the same address to which those requests arrived and via the same interface through which they arrived, otherwise the responses will not get properly un-dst-nated and the client will not recognize them even if the ISP lets them get through despite their incorrect (from its perspective) source address. This part seems to be configured properly as the response did come back to the Mikrotik although its destination was a public address somewhere in the internet, so without policy routing, it would have taken the other route.

However, most server processes can be told to listen on all addresses of the server or only on specific ones. So if the incoming connections to port 3389 are actively rejected (sniffing as described earlier will clearly show whether it is the case), the reason may be that the process only listens on other address(es) than 192.168.88.200; in such a case (and several other ones), the TCP stack would reject the connection by sending a RST packet in response to the SYN one.
I think most Linux servers have an SSH service running on port 22, that's why so the service is already there. The ether1 interface that is connected to the ONU will be disconnected, but first, I just want to make sure that everything is properly configured on the ether2 interface on the server.
 
User avatar
sindy
Forum Guru
Forum Guru
Posts: 11228
Joined: Mon Dec 04, 2017 9:19 pm

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 8:11 pm

first, I just want to make sure that everything is properly configured on the ether2 interface on the server.
That's a proper approach but I'm not sure how is that related to what I wrote.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 22089
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: dstnat doesn't work on L009UiGS-RM Router

Sun Dec 29, 2024 8:27 pm

Nice to know at the last minute that the server is directly connected to the ONT. That is a slap upside your head moment.
So besides two bizarro connections from the MT to the ISP device, you have a third ISP connection directly to the Server.

Suggestion, remove connection directly to the ISP device.... and let MT handle all the connections..............
Sindy should charge overtime for linux server (nothing to do with mikrotik) help. ;-)

Who is online

Users browsing this forum: BartoszP, eltrocadero2, LouisdeBussy, sinisa and 41 guests