Skip to content

Firewall is not working for IPSec NAT-T #53

@kouhj

Description

@kouhj

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 the mangle table with this command iptables -t mangle -I POSTROUTING -m policy --pol ipsec --dir out -j NFLOG --nflog-group 5. The key seems how to add a nftables rule in POSTROUTING chain of the nat table like the command iptables -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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions