Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Register
    • Login
    Introducing Netgate Nexus: Multi-Instance Management at Your Fingertips.

    IPsec policy-based traffic bypassed for forwarded packets: ip_tryforward active despite global SPD entries (mobile IKEv2 + VTI coexistence)

    Scheduled Pinned Locked Moved IPsec
    3 Posts 2 Posters 116 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • YamkaY
      Yamka
      last edited by

      Hello everyone :)

      On a firewall running both route-based IPsec (several VTI tunnels) and policy-based mobile IKEv2, mobile clients can reach the firewall’s own interface addresses, but no host behind the firewall.

      Our investigation shows that forwarded reply traffic is not matched against the IPsec SPD. Instead, it is sent unencrypted out of the WAN to the default gateway. The kernel fast forwarding path (ip_tryforward) is being used even though global IPsec security policies are installed. Adding a single dummy global policy with setkey restores normal behavior immediately.

      Environment
      • pfSense CE 2.8.1-RELEASE, Intel ix NICs.
      • Mobile IPsec IKEv2, policy-based. Virtual address pool 172.16.99.0/24. Several local networks pushed to clients, for example 192.168.0.0/20, 192.168.20.0/24, 192.168.30.0/24. Internal networks sit on VLAN interfaces (ix1.20, ix1.30, …), with the firewall as gateway (.254).
      • Several route-based VTI tunnels in production (ipsecX interfaces). Their SPD entries are 0.0.0.0/0 with scope=ifnet.
      • IPsec filtering on enc0 (IPsec tab). The rule passing mobile client traffic has no gateway, no route-to, no reply-to and no dup-to.
      • The same behavior occurs with two different clients: strongSwan on Linux and TheGreenBow on Windows.

      Symptoms
      • The IKE SA and CHILD_SA are established. Traffic selectors are correct (all local networks to the client’s /32 virtual IP).
      • The SPD contains the expected global policies in both directions, for example 192.168.20.0/24 -> 172.16.99.1 out ipsec esp/tunnel/<WAN>-<client>/unique:1, scope=global.
      • Internal hosts receive the client’s requests and reply to the firewall, as seen in captures on the VLAN interfaces.
      • The client receives replies from the firewall’s own addresses (for example 192.168.20.254), but never from any host behind it, on any internal network.
      • A capture on the WAN interface (-Q out) shows the replies from internal hosts leaving in cleartext, with destination MAC of the WAN gateway and no NAT applied. Replies generated by the firewall itself, captured at the same time, do not appear in cleartext: they are correctly ESP-encapsulated.
      • The lastused timestamp of the outbound SPD entries for the internal networks does not change while forwarded replies are sent.

      Findings

      1. pf is not involved. The relevant rule has no route option, no floating rule matches this traffic, and the states carry no route information.
      2. The SPD is consistent. There is no competing global policy: the only out none entry is the usual LAN bypass (192.168.0.0/20 -> 192.168.0.0/20), and all 0.0.0.0/0 entries are VTI policies with scope=ifnet.
      3. Forwarding statistics (netstat -s -p ip) show that almost all forwarded packets go through fast forwarding. Over two 10-second samples, 122,833 of 122,848 and 32,191 of 32,203 forwarded packets were fast forwarded. Since boot, however, only about 72 M of 3.38 G forwarded packets (about 2 %) were fast forwarded. This suggests the system recently switched from the normal forwarding path to the fast path.
      4. Our understanding is that ip_input() should skip ip_tryforward() when IPsec security policies are present (IPSEC_CAPS(..., IPSEC_CAP_OPERABLE)). The kernel behaves as if no global policy existed, although setkey -DP lists several. We suspect inconsistent accounting of security policies, possibly triggered by the coexistence of ifnet-scoped (VTI) and global (mobile) policies, or by VTI/CHILD_SA rekeys or reinstalls. This is a hypothesis; we cannot confirm the exact root cause.

      Workaround (confirmed)
      Adding one dummy global policy using documentation addresses restores correct behavior immediately:
      echo 'spdadd 192.0.2.1/32 198.51.100.1/32 any -P out none;' | setkey -c
      Right after this, the fast forwarded counter stops increasing completely (0 fast forwarded packets out of about 28,000 forwarded in 10 seconds). Forwarded replies are encapsulated in the CHILD_SA, mobile clients reach all internal hosts, and the VTI tunnels keep working normally.
      This workaround is not satisfactory for production. The policy lives outside the pfSense configuration, is not shown in the GUI or included in backups, and is lost on reboot and possibly on IPsec reload. Keeping it in place would require a periodic cron job or a manual procedure, which we would prefer to avoid.

      Questions

      1. Is this a known issue in 2.8.1 (pfSense or the underlying FreeBSD IPsec/ip_tryforward code)?
      2. Does 2.9.0 fix this behavior? If so, could you point us to the related change or issue?
      3. If not yet fixed, is there a supported, configuration-managed way to prevent fast forwarding from bypassing policy-based IPsec until a fix is available?
      4. Are there diagnostics you would like us to collect the next time the issue appears, for example right after a reboot or a VTI rekey?

      We can provide additional command outputs on request, thank you very much in advance for your answer :)

      1 Reply Last reply
      Reply Quote 0
      • tinfoilmattT
        tinfoilmatt LAYER 8
        last edited by

        Assuming no configuration oversight anywhere, this could be a valid Redmine. A couple additional points you'd maybe want to mention:

        Is this a multi-WAN system you're seeing this on? Or just a single WAN?

        Is there a explicitly-defined IPv4 default gateway (under System > Routing > Gateways)? Or is it set to 'Automatic'?

        Did this start happening suddenly? Or was it only recently discovered when configuring mobile IPsec for the first time (with pre-exisiting route-based IPsec configuration)?

        block out log on { ix0 } inet from any to any
        block out log on { ix0 } inet6 from any to any

        YamkaY 1 Reply Last reply
        Reply Quote 0
        • YamkaY
          Yamka @tinfoilmatt
          last edited by

          @tinfoilmatt

          Hello! Thank you very much for your intervention and sorry for the delayed answer :)

          Here is the complementary information :

          1. WAN configuration
          Single WAN, with a single upstream gateway. We also have one gateway per VTI tunnel (route-based IPsec), but mobile clients use no gateway at all: the enc0 rule passing their traffic has no gateway set.

          We checked the generated pf ruleset and found route-to and reply-to entries associated with the WAN interface (ix0), but none associated with enc0. No dup-to was identified on enc0 either.

          2. Default IPv4 gateway
          The IPv4 default gateway (System > Routing > Gateways) is set to Automatic.

          VTI gateways are not part of any gateway group, and no gateway groups are configured. We also verified the effective routing table: the active default route points to the WAN gateway through ix0, not through any VTI interface.

          3. When the issue started
          Unfortunately, we have no precise starting point.
          What we can say is that since the last boot (approximately 14 days ago, around October 22, 2026), only about 2% of forwarded packets had gone through fast forwarding (about 72 M out of 3.38 G).
          However, when we investigated, nearly 100% of forwarded packets were being fast forwarded during two consecutive 10-second samples.

          This suggests that forwarding behavior may have changed at some point during the current uptime, although we cannot determine exactly when or what triggered it.
          One possible trigger would be a VTI gateway or tunnel event. In the available gateway logs (since October 11, 2026), we found gateway monitoring events involving latency and packet loss. We also observed successful VTI CHILD_SA rekeys on November 5, 2026.

          However, the available IPsec logs rotate frequently (approximately every 7–8 minutes) and do not cover the suspected period, so we cannot establish a correlation between these events and the issue.

          4. Additional observations and workaround
          To be precise about the symptom: during the failure, forwarded replies did not go through IPsec processing at all. They left the WAN in cleartext towards the default gateway, while replies generated by the firewall itself were correctly ESP-encapsulated.

          Adding a single dummy global security policy (SP) with setkey immediately stopped the fast-forwarded packet counter from increasing and restored connectivity to internal hosts for mobile IPsec clients, without any other configuration changes.
          The dummy SP is still present in the SPD (scope=global, out none), and the issue has not reappeared while the workaround is active.

          During our latest verification on November 5, the firewall forwarded 27,084 packets over 10 seconds, with 0 additional fast-forwarded packets. The fast-forwarded counter remained unchanged at 73,179,263.

          We also observed successful VTI CHILD_SA rekeys during this period, without any apparent impact on the workaround.
          However, we cannot confirm whether the dummy SP would survive a firewall reboot or IPsec service restart without being re-applied.

          Version: pfSense CE 2.8.1-RELEASE.

          Thank you again for your assistance and don't hesitate if you need any other informations :)

          1 Reply Last reply
          Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          Copyright 2026 Rubicon Communications LLC (Netgate). All rights reserved.
          Privacy Policy · Cookie Policy