ENV: A L3 fixed line from ISP. A single public /32 ip address, static route from ISP, connected to ISP with private /30 IP address.
DEVICE: hEX S
Version: latest v6.45.7
My HEX S:
IP ADDRESS:
sfp1: 100.68.39.194/28 (UPLINK TO ISP, GATEWAY: 100.68.39.193)
bridge1(Ether1~5): 192.168.0.1/24 (MY LAN)
loopback0(A bridge to simulate loopback interface of cisco): 59.43.27.9/32 (Public IP address from my ISP)
I need to USE this single ip in my office. So I copied configuration and translate it to RouterOS’s configuation from my original H3C router.
/32 IP address assign to loopback interface, and disable masquerade, use src-nat to this address.
Just brainstorming from my part: is it really necessary to play with the “fake” bridge just to assign the /32 address to some interface? From ISP side packets with dst-address=/32 will just get routed to your RB. From LAN side it doesn’t get used at all. So it’s all internal to RB and thus you don’t need interface bearing it just to perform NAT on those packets …
If there’s no interface bearing IP address, then packet with such dst-address simply can’t be subject to chain=input …
Well, I guess you are right, if you don’t need any routing protocol like OSPF announce the route to this address automatically, you can always workaround assigning the address somewhere by dst-nat to any other router’s address. But what’s the point?
Address assigned to the loopback bridge is not the reason that dst-nat doesn’t work.
The rule is clear, if it’s tcp connection to 59.43.27.9:8443, it’s redirected to 192.168.0.250:443. And if 192.168.0.250 is another device, it can’t end up in input chain. Does this dstnat rule get any hits? Can’t there be some other before this one that would take it and redirect it to router?
About the address, you can assign it to router, route it further to another device, or even don’t assign it anywhere. But the last option is not very good. It’s probably not too bad if you’d use it for 1:1 NAT, but not if you’re going to dstnat only one port. What if packet comes for another port? Router will say “no thanks” and will forward it back to ISP and they will play ping-pong until TTL expires.
It would. But it’s easier to assign address to router and let it handle automatically. OP’s config is fine, but there must be also something else we don’t see.
@realpg, I guess @Sob’s “there must be something we don’t see” is just another wording of “please post the complete (anonymized) configuration rather than just a few lines you assume to be relevant”.
But giving it a try without seeing the full configuration, your dst-nat rule itself is OK, so these are the only configuration-related things I can imagine to prevent it from working:
another rule in the dstnat chain which shadows it, but such an elementary mistake doesn’t match the tone of your OP,
something (an action=notrack rule in /ip firewall raw) preventing connection tracking from handling the packets, which allows them to reach filter but not nat. Even experienced users may not realize that NAT functionality is provided by the connection tracking module.
What is your rule in input chain that is being hit by these packets?
Can you add the explicit condition dst-address=59.43.27.9 to it?
My guess is that your ISP is NATing packets with your public IP as a dst-address to you grey IP, instead of routing them to you as is.
That is possibly why they never hit dst-nat rule and end up in your input chain.
Easy to check that: change dst-address in your dst-nat rule to 100.68.39.194 and try to connect from outside to 59.43.27.9.
I’m afraid @xvo’s idea is correct but the formulation was not perfect.
The actual idea is to check, in the input chain, whether the packet which evades the dst-nat rule really arrives to the Mikrotik still with 59.43.27.9 as its dst-address or whether it gets dst-nated before, in the ISP network, by 1:1 NAT to your WAN IP from the shared range (100.64.0.0/12). So two rules at the very beginning of the input chain, action=log dst-address=59.43.27.9 and action=log protocol=tcp dst-port=8443, should answer this question after you try to connect to 59.43.27.9:8443 from the outside.
Yes, sindy, you are right, that’s what I had in mind.
My second idea, to change dst-nat dst-address (or use in-interface matcher instead) will prove the same point: if everything starts working “magically”, that will mean ISP is using 1:1 NAT instead of static routing.
How are these two statements related? Yes, the firewall does use the netfilter part of the kernel network stack; whether RouterOS firewall configures netfilter directly or by means of iptables is not important. However, there is nothing wrong about a dst-nat rule matching on your 100.68.39.194 as dst-address. If the ISP does a 1:1 dstnat, what you send from outside to 59.43.27.9 comes to your Tik with destination IP 100.68.39.194. All Mikrotik’s own services listen on all its local addresses (unless you specifically tell them not to), so it is easy not to notice that the ISP does the dst-nat.