Community discussions

MikroTik App
 
caswell1000
just joined
Topic Author
Posts: 12
Joined: Sun May 27, 2018 1:33 am

Hairpin NAT not working as expected

Wed Jul 03, 2019 9:03 am

Hi,
The picture shows the hairpin NAT I tried to setup, the action is masquerade, it does not work from inside the network, even when I insert the dst nat port and src nat port, please assist. Image

Sent from my VTR-L09 using Tapatalk

 
User avatar
Anumrak
Forum Guru
Forum Guru
Posts: 1174
Joined: Fri Jul 28, 2017 2:53 pm

Re: Hairpin NAT not working as expected

Wed Jul 03, 2019 3:43 pm

For hairpin NAT you need 3 rules, not just one.

Common rule for Internet interface with destiantion nat from public to private for inbound interface
Destination nat from public to private with your source for inbound local interface
Masquerade nat from your source to private destination for outbound local interface

More control! :)
 
KarelVDM
just joined
Posts: 11
Joined: Mon Jun 24, 2019 4:31 pm

Re: Hairpin NAT not working as expected

Wed Jul 03, 2019 10:17 pm

@Anumrak,
I also need Hairpin NAT. Could you be more specific in the setup? Give example CLI commands to setup?
I do have a Dynamic WAN IP and NOT a static WAN IP

Thanx
Karel
 
User avatar
petrb
Member Candidate
Member Candidate
Posts: 100
Joined: Thu Jan 26, 2017 4:17 pm

Re: Hairpin NAT not working as expected

Wed Jul 03, 2019 10:46 pm

for dstnat you can specify input interface instead ip + you need public ip at the wan and dyndns
 
Sob
Forum Guru
Forum Guru
Posts: 9121
Joined: Mon Apr 20, 2009 9:11 pm

Re: Hairpin NAT not working as expected

Wed Jul 03, 2019 11:45 pm

No, you can't specify in-interface for dstnat rule, because then it won't match packets coming from LAN.

It's really simple. If router has static public address (best case), do e.g.:
/ip firewall nat
add chain=dstnat dst-address=<public address> protocol=tcp dst-port=80 action=dst-nat to-addresses=192.168.88.10
add chain=srcnat src-address=192.168.88.0/24 dst-address=192.168.88.0/24 action=masquerade
(192.168.88.10 is internal server, 192.168.88.0/24 is local network, change it to what you have)

If public address is dynamic, then use this dstnat rule instead (srcnat rule stays the same):
/ip firewall nat
add chain=dstnat dst-address-type=local dst-address=!192.168.88.1 protocol=tcp dst-port=80 action=dst-nat to-addresses=192.168.88.10
(192.168.88.1 is router's LAN address and it's there to exclude connections to services on router from LAN side, in this case it could be WebFig on port 80)
 
caswell1000
just joined
Topic Author
Posts: 12
Joined: Sun May 27, 2018 1:33 am

Re: Hairpin NAT not working as expected

Thu Jul 04, 2019 2:58 am

Thanks @Sob, it works.

Sent from my VTR-L09 using Tapatalk

Who is online

Users browsing this forum: complexxL9, sotahe9145, tdw and 214 guests