Port-forward through IPSEC Tunnel with PBR
We have a Firewall in our DataCenter Colocation which has an IPSec Tunnel with a VTI back to our Office Firewall. Behind the Office Firewall is a Server which needs to be published to the Internet.
On the Office Firewall there is a Policy Based routing rule to forward all traffic from that Server via the Tunnel to the Datacenter.
If I'm opening a webpage or use speedtest.net I can see the correct public IP Address assigned from the NAT Pool on the Colocation Firewall.
Now if we open a port form the Colocation Firewall via Port Forward to the office Server, I can see the requests via Wireshark hitting the Colo Firewall, hitting the VPN Tunnel and the Office Firewall. So running a Packet Capture on the VTI Interface of the Office Firewall I can see the traffic hitting the Firewall with that tunnel, but the traffic is never leaving the tunnel and gets to the server.
Please have a look at the following forum post for more information and pictures of the setup.
https://forum.opnsense.org/index.php?topic=17381.0
Reproduction.
- Build a VPN Tunnel between two OPNsense or one OPNsense and one PFsense firewall with IPSec or OpenVPN. 1.a. if you use a PFSense this has to be the Firewall publishing the service.
- Create a portforward form the OPNsense/PFsense to a device hosted behind the other Firewall.
- Create a Policy based routing to forward all traffic from that device via the VPN tunnel to the OPNsense/PFsense device.
- You can now see that outbound traffic is forwarded via the VPN tunnel to the Internet, but inbound traffic gets dropped after it traveled through the VPN tunnel and never makes it to the LAN interface and to the server.
Expected behavior: I did test the same setup with a pure PFsense design as well as with a UBNT USG and a PFsense and they both forwarding inbound traffic to the server.
So this should work with OPNsense as well and not drop the traffic on the way from the VPN tunnel into the LAN.
Environment: OPNsense 20.7-amd64 FreeBSD 12.1-RELEASE-p7-HBSD OpenSSL 1.1.1g 21 Apr 2020
AMD Ryzen 5 3600 6-Core Processor (4 cores) ESXi 6.7 4GB RAM vmxnet3
I will provide wireshark captures later today. Since I need to build up the test setup again.
Best regards Martin
You say it's dropped, do you see somethin in filter.log? With VTI you also get a new interface in Firewall where you have to place rules.
Can you check via sysctl these values in your pfsense and OPNsense system:
net.inet.ipsec.filtertunnel net.enc.out.ipsec_filter_mask net.enc.in.ipsec_filter_mask
Thanks for your answer. the filter.log is empty and not showing anything on both devices for the IPs in question.
Here are the values for sysctl:
OPNsense: root@DE-S01-FW001:~ # sysctl net.inet.ipsec.filtertunnel net.inet.ipsec.filtertunnel: 0 root@DE-S01-FW001:~ # sysctl net.enc.out.ipsec_filter_mask net.enc.out.ipsec_filter_mask: 1 root@DE-S01-FW001:~ # sysctl net.enc.in.ipsec_filter_mask net.enc.in.ipsec_filter_mask: 2
Pfsense: [2.4.5-RELEASE][[email protected]]/root: sysctl net.inet.ipsec.filtertunnel net.inet.ipsec.filtertunnel: 0 [2.4.5-RELEASE][[email protected]]/root: sysctl net.enc.out.ipsec_filter_mask net.enc.out.ipsec_filter_mask: 1 [2.4.5-RELEASE][[email protected]]/root: sysctl net.enc.in.ipsec_filter_mask net.enc.in.ipsec_filter_mask: 2
We did rip everything apart and did a new setup and it behaves quite differently as the first time. I attached several files to this post. There is a Topology.png to understand the setup and several pcap files.
We did run Wireshark on the Server during our test and we could see traffic from our test client coming into the server. You can see that in the server.pcap file, if you apply a filter for ip.addr==213.231.155.207 you can see that the Client is requesting traffic and the server is answering to it.
Next is a pcap file packetcapture_vmx0.cap taken on the LAN interface of the OPNsense firewall. Here you can see as well, that the answer from the Server makes it to the Firewall.
Next two files are packetcapture_enc0.cap and packetcapture_ipsec2000.cap. Those are the captures taken on the VTI Tunnel Interface and the IPSEC interface. Here you can see that the packet accepted on the LAN Interface never makes it into the tunnel.
Also I attached pictures of the Rules for the PBR to put all traffic into the Tunnel (PBR-LAN.png). Which works without an issue. If we do a speedtest or whatismyip.com it shows us the IP for the Firewall on the other end of the tunnel.
the capture files are in a ZIP and password is opn123$.
Also I attached Rules-IPSec.png and Rules-VTI.png which show the rules of the VTI and IPSEC/ENC interface.

Best regards Martin
Screenshot of portforwarding?
Here the screenshot of the PortForward:

Also here the IPSec Rules of the Pfsense:

This issue has been automatically timed-out (after 180 days of inactivity).
For more information about the policies for this repository, please read https://github.com/opnsense/core/blob/master/CONTRIBUTING.md for further details.
If someone wants to step up and work on this issue, just let us know, so we can reopen the issue and assign an owner to it.
Sorry to open this up again. Has this ever been solved? We have the same issue. Want to publish Webserver beging IPSEC Tunnel.
Yes, there is on filter rules a disable repl-to option where you can set the correct gateway
Thank you! I get the idea, but can you explain a bit... do I have to create a Gateway there which points to the "MainSiteIP"?
For PBR you always need a gateway, so yes, a gateway on enc0 but I never tested it on a policy based tunnel.