HAIRPIN HAT not working

here is my config, i can access via internet, but not from the local lan! can someone help me?

add action=dst-nat chain=dstnat comment=“OPEN 443 WEB, RULE 25-40 PACKETS PER SECOND” dst-address-type=“” dst-limit=25,40,dst-address/1m dst-port=443
in-interface=all-ethernet log=yes log-prefix=“WEB CONNECTION” protocol=tcp to-addresses=192.168.10.10 to-ports=443
add action=dst-nat chain=dstnat dst-port=80 in-interface=ether1 protocol=tcp to-addresses=192.168.10.10 to-ports=80

I ADDED these two lastly, after 230942 attempts to make it work, but i continuos wrong.

add action=masquerade chain=srcnat dst-address=192.168.10.10 dst-address-type=“” protocol=tcp src-address=192.168.10.0/24
add action=masquerade chain=srcnat dst-address=192.168.10.1 dst-address-type=local protocol=tcp

try to add this one

/ip firewall nat add action=netmap chain=dstnat dst-address=WAN_IP dst-port=443,80 protocol=tcp to-addresses=192.168.10.10

thanks for your reply, but still can not enter from local lan.. i can from outside of the office..

Read this: viewtopic.php?f=2&t=126724&p=623599#p623599 post and quoted thread in it.

or directly this: http://forum.mikrotik.com/t/port-forwarding-problem/93224/14

after you dst-nat from global to LAN, add these 2 rules:
ip firewall nat
add action=dst-nat chain=dstnat dst-address=“your global IP” dst-port=80 in-interface=“LAN interface for your web server”
protocol=tcp src-address=192.168.10.0/24 to-addresses=192.168.10.10 to-ports=80
add action=masquerade chain=srcnat dst-address=192.168.10.10 dst-port=80 out-interface=“LAN interface for your web server” protocol=tcp src-address=192.168.10.0/24

It is better to do src-nat with specified IP instead of masquarade.

still not working :S . thanks dude

how would you change what he said?

also i tried this
add action=masquerade chain=srcnat comment=“Hairpin NAT Masq” disabled=yes out-interface=ether1 src-address-list=Local
add action=netmap chain=dstnat disabled=yes dst-address=“wanip” dst-port=443,80 protocol=tcp src-address-list=
Local to-addresses=192.168.10.10

and there if i look on packets, they start to flush, but still cannot reach the site

Set only three rules. Simple dst-nat for connectivity from Internet and my previous 2 rules to hook the global IP from LAN. With this setup I have web access to web resource with global IP from LAN.
First rule is
ip firewall nat
add action=dst-nat chain=dstnat dst-port=80 in-interface=“your global interface”
protocol=tcp to-addresses=192.168.10.10 to-ports=80

Ok my friend, now i have only these rules enabled.
/ip firewall nat
1 chain=dstnat action=dst-nat to-addresses=192.168.10.10 to-ports=443 protocol=tcp dst-address-type=local in-interface=ether1 dst-port=443
dst-limit=25,40,dst-address/1m log=yes log-prefix=“WEB CONNECTION”

9 chain=dstnat action=dst-nat to-addresses=192.168.10.10 to-ports=443 protocol=tcp src-address=192.168.10.0/24 dst-address=“GLOBAL IP” in-interface=ether1
dst-port=443

10 chain=srcnat action=masquerade protocol=tcp src-address=192.168.10.0/24 dst-address=192.168.10.10 out-interface=ether1 dst-port=443

not working, idk why

ether1 is LAN interface or WAN?
your 9 and 10 rules must have LAN interface. 9 rule in and 10 is out

ether1 is my wan.. but if i put the etherX where i have my server, it doesn’t let me finish the rule, an error pop out

What rule exacly? Maybe your LAN interface belongs to some master port or bridge? Then, you need point this bridge or master port in 9 and 10 rules. Or you have to extract this port from bridge or slave entity. You have to point LAN interface of your web server, otherwise you can’t establish hairpin nat mechanic.

now you say that, i have this rule, created by mikrotik itself, i never wrote this.
chain=srcnat action=masquerade out-interface=ether1 log=no log-prefix=“”

I’m talking about 9 and 10 rules only. Forget about classic masquerade. Change interfaces on them.

men, you are a f********ng GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOD! if i could, i would go to you and give you a hug men jaja

Your welcome :smiley:

i have exactly same problem like @rodrigobenta
i've tried a lot of solution from google search and mikrotik forum search.

@rodrigobenta, please share me all rules. i want give a hug too :slight_smile:

@Anumrak, your solution have not worked for me.

i want to reach to local server (192.168.0.52) in local network (my local ip: 192.168.0.165) with external ip (1.1.1.10). (My external IP is static)
When i try reach from out network (e.g. 2.2.2.2) to (1.1.1.10) -> SUCCESS
When i try reach from in network (192.168.0.165) to (192.168.0.52) -> SUCCESS
When i try reach from in network (192.168.0.165) to (1.1.1.10) -> FAIL : ERR_CONNECTION_REFUSED

RouterOS 6.40.1
RouterBOARD 3011UiAS

/ip firewall nat export
add action=masquerade chain=srcnat dst-address=192.168.0.52 dst-port=629 out-interface=Local protocol=tcp src-address=192.168.0.0/24
add action=dst-nat chain=dstnat dst-address=1.1.1.10 dst-port=629 in-interface=Local protocol=tcp src-address=192.168.0.0/24 to-addresses=192.168.0.52 to-ports=629
add action=masquerade chain=srcnat out-interface=RADIO-LINK src-address=192.168.0.0/24
add action=dst-nat chain=dstnat dst-port=629 in-interface=RADIO-LINK protocol=tcp to-addresses=192.168.0.52 to-ports=629


/interface print
Flags: D - dynamic, X - disabled, R - running, S - slave

NAME TYPE ACTUAL-MTU L2MTU MAX-L2MTU

0 R ;;; [ETH1]-LINK_GIRIS
RADIO-LINK ether 1500 1598 8156
1 R ;;; [ETH2]-VDSL_GIRIS
VDSL-ETH ether 1500 1598 8156
2 S ether3 ether 1500 1598 8156
3 S ether4 ether 1500 1598 8156
4 S ether5 ether 1500 1598 8156
5 RS ether6 ether 1500 1598 8156
6 RS ether7 ether 1500 1598 8156
7 RS ether8 ether 1500 1598 8156
8 S ether9 ether 1500 1598 8156
9 S ether10 ether 1500 1598 8156
10 sfp1 ether 1500 1600 8158
11 R ;;; [ETH3-ETH10]-LOCAL_NETWORK_192.168.0.1/24
Local bridge 1500 1598

/ip address print
Flags: X - disabled, I - invalid, D - dynamic

ADDRESS NETWORK INTERFACE

0 1.1.1.10/30 1.1.1.8 RADIO-LINK
1 10.1.1.121/24 10.1.1.0 VDSL-ETH
2 192.168.0.1/24 192.168.0.0 Local

I have 2 INTERNET input. (Load balancing in local network)
RADIO-LINK connect on port 1 directly.
RADIO-LINK's static IP is: 1.1.1.10
VDSL-ETH connect port 2 over adsl modem.

mikrotik support team from in my country (TR) say this is not possible. But i can see from videos and forum posts that can be done.

It is possible? Where do i make mistakes?

In your

/ip firewall nat export

, I can see you translate the source IP of the TCP requests, coming from your local subnet and forwarded to the server at 192.168.0.52, to Mikrotik’s own IP address using the following rule:

add action=masquerade chain=srcnat dst-address=192.168.0.52 dst-port=629 out-interface=Local protocol=tcp src-address=192.168.0.0/24

This forces the server at 192.168.0.52 to send the response to Mikrotik rather than directly to the client (which would normally be the case as the client and the server are in the same subnet).

But even though the response packet is forced through Mikrotik this way, the client in 192.168.0.0/24 still gets the response from 192.168.0.52 while it has sent its request to 1.1.1.10, which may confuse it. Now a srcnat rule implicitly creates, thanks to “connection tracking”, an equivalent of a dstnat rule for the opposite direction, so the Mikrotik changes the destination IP in the received response from its own one to that of the real client. However, I’m not sure the same is the case for dstnat rules. So I would manually add another srcnat rule, mirroring the dstnat one which would translate the destination IP of the request from 1.1.1.10 to 192.168.0.52:

add chain=srcnat src-address=192.168.0.52 protocol=tcp src-port=629 out-interface=Local action=srcnat to-addresses=1.1.1.10 to-ports=629

i added too this src-nat rule. should i remove dst-nat rule?

all of rules are like this: (bold line is newly added)

add action=masquerade chain=srcnat dst-address=192.168.0.52 dst-port=629 out-interface=Local protocol=tcp src-address=192.168.0.0/24
add action=dst-nat chain=dstnat dst-address=1.1.1.10 dst-port=629 in-interface=Local protocol=tcp src-address=192.168.0.0/24 to-addresses=192.168.0.52 to-ports=629
add action=masquerade chain=srcnat out-interface=RADIO-LINK src-address=192.168.0.0/24
add action=dst-nat chain=dstnat dst-port=629 in-interface=RADIO-LINK protocol=tcp to-addresses=192.168.0.52 to-ports=629
add action=src-nat chain=srcnat out-interface=Local protocol=tcp src-address=192.168.0.52 src-port=629 to-addresses=1.1.1.10 to-ports=629


unfortunately still not working :frowning:

when i check with torch, only 1 package showing, then connection refused. Red area is RADIO-LINK’s external IP (eg: 1.1.1.10)
mikrotik-nat-problem-20180113.PNG