0xid0
September 22, 2020, 12:35am
1
Hi,
I have the next setup:
ISP router (192.168.0.1) → Hap AC2 (192.168.0.2 for the ISP router - 192.168.1.1 for the LAN) → devices
And i have the next problem: if i try to access to my internal services, i only can via private IPs. If i try to access from the same LAN to one of my services like webserver via public IP, i can’t reach. But if i try from another network (like mobile phone without connecting to the wifi), it works.
My current setup is the next:
0 chain=srcnat action=masquerade out-interface-list=WAN log=no log-prefix=“”
1 ;;; adguard
chain=dstnat action=dst-nat to-addresses=192.168.1.60 to-ports=853
protocol=tcp dst-address=192.168.0.2 in-interface=all-ethernet
dst-port=853 log=no log-prefix=“”
2 D ;;; upnp 192.168.1.10: 54cfaca957523bb98db6ce66dea85c0c-Web Admin
chain=dstnat action=dst-nat to-addresses=192.168.1.10 to-ports=8080
protocol=tcp dst-address=192.168.0.2 in-interface=ether1 dst-port=8080
3 D ;;; upnp 192.168.1.10: 54cfaca957523bb98db6ce66dea85c0c-Secure Web Admin
chain=dstnat action=dst-nat to-addresses=192.168.1.10 to-ports=443
protocol=tcp dst-address=192.168.0.2 in-interface=ether1 dst-port=443
4 D ;;; upnp 192.168.1.10: 54cfaca957523bb98db6ce66dea85c0c-SSH/SFTP
chain=dstnat action=dst-nat to-addresses=192.168.1.10 to-ports=2202
protocol=tcp dst-address=192.168.0.2 in-interface=ether1 dst-port=2202
5 D ;;; upnp 192.168.1.10: 54cfaca957523bb98db6ce66dea85c0c-Secure Web Serve
chain=dstnat action=dst-nat to-addresses=192.168.1.10 to-ports=8081
protocol=tcp dst-address=192.168.0.2 in-interface=ether1 dst-port=8081
protocol=tcp dst-address=192.168.0.2 in-interface=ether1 dst-port=8081
6 D ;;; upnp 192.168.1.12: DemonwarePortMapping
chain=dstnat action=dst-nat to-addresses=192.168.1.12 to-ports=3075
protocol=udp dst-address=192.168.0.2 in-interface=ether1 dst-port=3075
7 ;;; masq. vpn traffic
chain=srcnat action=masquerade src-address=192.168.89.0/24
Someone can help me, please? Thanks!
xvo
September 22, 2020, 9:30am
2
Search for “hairpin nat”.
And as you are behind an ISP router, you should probably implement it there, not on mikrotik.
0xid0
September 22, 2020, 11:18am
3
Search for “hairpin nat”.
And as you are behind an ISP router, you should probably implement it there, not on mikrotik.
Yesterday i saw some posts about “hairpin nat” and tried to implement, but still doesn’t work (currently are not implemented as you can see in the FW rules).
In ISP router i have DMZ rule to the Mikrotik router IP. I need to do something else? ISP router are very basic and limited.
anav
September 22, 2020, 11:22am
4
If you post your entire config I will have a look
/export hide-sensitive file=anynameyouwish
xvo
September 22, 2020, 11:39am
5
How exactly did you try to implement hairpin nat?
As your public IP is not assigned to your mikrotik but to the ISP router, you should add an additional regular dst-nat rule together with the hairpin (src-nat) one.
anav
September 22, 2020, 4:23pm
7
/ip address
add address=192.168.1.1/24 interface=ether2 network=192.168.1.0
should be
/ip address
add address=192.168.1.1/24 interface=bridge1 network=192.168.1.0
For Hairpin NAT
/ip firewall nat
add action=masquerade chain=srcnat source-address=192.168.1.0/24 destination-address=192.168.1.0/24
add action=masquerade chain=srcnat out-interface-list=WAN **
add action=dst-nat chain=dstnat comment=adguard dst-address=192.168.0.2
dst-port=853 protocol=tcp to-addresses=192.168.1.60 to-ports=853
add action=masquerade chain=srcnat comment=“masq. vpn traffic” src-address=
192.168.89.0/24
ALSO if you have a fixed wanip I believe its 192.168.0.2
then your first masquerade rule should be
** add chain=srcnat action=src-nat out-interface=ether1 to-addresses=192.168.0.2 (vice the masquerade action default rule).
But do you have a second wan input? WLAN2?? if you do and its dynamic
add chain=srcnat action=masquerade out-interface=wlan2 or if its fixed IP as well
add chain=srcnat action=src-nat out-interface=wlan2 to-addresses=x.x.x.x
0xid0
September 22, 2020, 6:59pm
8
/ip address
add address=192.168.1.1/24 interface=ether2 network=192.168.1.0
should be
/ip address
add address=192.168.1.1/24 interface=bridge1 network=192.168.1.0
For Hairpin NAT
/ip firewall nat
add action=masquerade chain=srcnat source-address=192.168.1.0/24 destination-address=192.168.1.0/24
add action=masquerade chain=srcnat out-interface-list=WAN **
add action=dst-nat chain=dstnat comment=adguard dst-address=192.168.0.2
dst-port=853 protocol=tcp to-addresses=192.168.1.60 to-ports=853
add action=masquerade chain=srcnat comment=“masq. vpn traffic” src-address=
192.168.89.0/24
ALSO if you have a fixed wanip I believe its 192.168.0.2
then your first masquerade rule should be
** add chain=srcnat action=src-nat out-interface=ether1 to-addresses=192.168.0.2 (vice the masquerade action default rule).
But do you have a second wan input? WLAN2?? if you do and its dynamic
add chain=srcnat action=masquerade out-interface=wlan2 or if its fixed IP as well
add chain=srcnat action=src-nat out-interface=wlan2 to-addresses=x.x.x.x
Thank you so much, but unfortunately still not working, now is configured like this (following your advices):
add address=192.168.1.1/24 interface=bridge1 network=192.168.1.0
add action=src-nat chain=srcnat out-interface=ether1 out-interface-list=WAN to-addresses=192.168.0.2
add action=dst-nat chain=dstnat comment=adguard dst-address=192.168.0.2 dst-port=853 protocol=tcp to-addresses=192.168.1.60
to-ports=853
add action=masquerade chain=srcnat comment=“masq. vpn traffic” src-address=192.168.89.0/24
0xid0
September 22, 2020, 7:01pm
9
Could you bring me an example of this dst-nat rule, please?
xvo
September 22, 2020, 7:39pm
10
/ip firewall nat add action=dst-nat chain=dstnat dst-address=your_public_IP to-addresses=192.168.1.60
And with it the hairpin rule:
/ip firewall nat add action=src-nat chain=srcnat dst-address=192.168.1.60 src-address=192.168.1.0/24 to-addresses=192.168.1.1
xvo
September 22, 2020, 10:03pm
12
Can’t see anything else in your config, that could interfere with it.
Apart from what @anav had already pointed out (address being assigned to the wrong interface).