We need to port forward a few services through a IPSEC tunnel to a server on another site. How to set this up, we already have a configured IPSEC tunnel up and running
Site A
WAN IP: 1.1.1.1
INT IP: 172.16.0.0/16
want to port forward port 80 to 172.17.10.10 in site B
Site B
WAN IP: 2.2.2.2
INT IP: 172.17.0.0/16
want to receive packets on port 80 through site A on 1.1.1.1
[Internet]->1.1.1.1:80 (WAN Site A) → [IPSEC tunnel] → 172.17.10.10:80 (LAN Site B)
It should probably work using two NAT rules. One standard port forward, dstnat 1.1.1.1:80 to 172.17.10.10:80. And then masquerading the source of forwarded packets to match IPSec policy, srcnat everything for 172.17.10.10:80 to 172.16.?.? (whatever address router has).
It’s very simple. Using addresses from original post, client connects from x.x.x.x (its own address) to 1.1.1.1:80. Dstnat rule changes destination to 172.17.10.10:80. But source address remains x.x.x.x and because the tunel is configured to only forward stuff between 172.16.0.0/16 and 172.17.0.0/16, it won’t take packet from x.x.x.x. So in addition to changing destination, you also need to change source:
/ip firewall add chain=srcnat dst-address=172.17.10.10 protocol=tcp dst-port=80
action=src-nat to-addresses=172.16.1.1You’ll end up with packet from 172.16.1.1 to 172.17.10.10:80 and that can go through tunnel just fine. Reply will come back through tunnel and thanks to contrack it will be correctly rewritten back to packet from 1.1.1.1:80 to x.x.x.x and everything will work.
Even though it works, this solution is not completely correct, because it will catch and change source of all packets going to 172.17.10.10:80. So if for example you’d like to access 172.17.10.10:80 directly from 172.16.0.0/16 and want server to see individual addresses, instead of just 172.16.1.1, you’d have to exclude this traffic from that srcnat rule.
Hello,
i have a similar situation, it works but the speed is slow when using ext IP from Local site A to access port 80 on one server from site B.
The speed is max 5-6 Mbps but if i do speed test directly from site A to site B speed is about 40 Mbps.
Also speed from site A/B to Internet is 100 Mbps download / 50 Mbps upload.
What can be the issue ?
Hmm,
i had 1 unlimited queue once i disabled it traffic got to 18 Mbps instead of 5, but is not stable… oscillating a lot
Processor is about 50 %
Much better anyway
Ok, I’m trying to follow this guide but I’m struggling.
The attached file has the network diagram.
Currently I can acces devices on the remote LAN no worries. Trying to get a port from the internet however, much tougher.
Here are the relevant parts of the firewall from the HAP ac
add action=dst-nat chain=dstnat comment=“Port Translation for Work Cisco SSH” dst-port=50003 in-interface=ether1 protocol=tcp to-addresses=192.168.6.1 to-ports=22
add action=src-nat chain=srcnat dst-address=192.168.6.1 dst-port=23 protocol=tcp to-addresses=192.168.1.200 to-ports=22
The first line is getting hits when I try use it so I suspect that is working.
The second line is getting no hits so I suspect its munted somehow. The source address change address (underlined) I dont really know what to use here, do I use the bridge IP or what?
From the mAP lite the relevant firewall rules
/ip firewall nat
add action=accept chain=srcnat dst-address=192.168.1.0/24 src-address=192.168.6.0/24
add action=masquerade chain=srcnat out-interface=wlan1
As always, I recommend to use IPIP or GRE tunnel over IPsec (enter IPsec key in the interface definition)
instead of IPsec tunnel. It will all work just like a normal ethernet link and standard recipes can be used
for port forwarding.
No it is not L2, that would be an EoIP tunnel. But it can be configured with IP like you would configure a normal
ethernet link, i.e. with IP addresses, and firewall rules.
Dynamic address would be no problem I think, I have no experience with that.