-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firewall is not working for IPSec NAT-T #53
Comments
Does iptables-translate (or iptables-nft) do the conversion for you? |
No. this tools does not work: I did the conversion by myself as in the previous post by adding a rule to |
Maybe something like |
Also
And save it to /etc/nftables.d/something.nft , kept over sysupgrade unlike other options. |
Following this article: https://thermalcircle.de/doku.php?id=blog:linux:nftables_demystifying_ipsec_expressions, I stopped firewall4 and import the following nft rules and it worked just fine.
So next step is how to integrate with firewall... |
Finally managed to make it work by adding a custom nft rule:
Good for a simple setup, but still something to do for multiple connections. |
Probably worth researching how to integrate rules into firewalld and amending strongswan docs with Your translation. |
multiple interfaces - prepend rulw iif {$wan_devices, $wwan_devices } filter your way. There is no "multiple source zones" option in fw4 |
Tested two OpenWRT 24.10 routers to setup a site to site IPSec connection with Strongswan when the WAN interfaces are over NATed network. After the firewall config were modified to accept the incoming ESP protocol and UDP 500, 4500 ports on the WAN interface (The default config of OpenWRT, which accepts redirecting ESP and UDP 500 to LAN, does not seem to work even to establish the connection), the two routers were able to establish the IPSec connection, and the following commands all reported normal results:
swanctl --list-sas
ip xfrm state
ip xfrm policy
ip route show table 220
BUT the normal site to site traffic just can get through when tested with ping.
If the firewall is stopped on the router that initiates the ping, it worked just fine to reach the other router. And unreachable again if the firewall is re-enabled.
Followed these articles,
https://docs.strongswan.org/docs/latest/howtos/forwarding.html
https://docs.strongswan.org/docs/latest/howtos/trafficDumps.html
and found that the LAN traffic can pass the
postrouting
chain of themangle
table with this commandiptables -t mangle -I POSTROUTING -m policy --pol ipsec --dir out -j NFLOG --nflog-group 5
. The key seems how to add a nftables rule inPOSTROUTING
chain of thenat
table like the commandiptables -t nat -I POSTROUTING -m policy --pol ipsec --dir out -j ACCEPT
pointed out in the Strongswan doc mentioned above.Tried the following and no luck:
nft insert rule inet fw4 srcnat oif WAN ipsec out reqid 1 counter accept
nft insert rule inet fw4 mangle_postrouting oif WAN ipsec out reqid 1 counter accept
The reqid 1 is confirmed with
swanctl --list-sas
Any ideas how to make IPSec NAT-T work with fw4? Thanks!
The text was updated successfully, but these errors were encountered: