Home / Notes / Firewall Policy + IPSec VPN Configuration
NOTES · FIREWALL / IPSEC VPN CONFIGURATION

Firewall Security Policy + IPSec VPN: Configuration Walkthrough

On a firewall, IPSec doesn't run on its own — every packet the tunnel sends or protects still has to clear the security-policy engine first. This is the configuration this note is based on: security zones and interfaces, IKE and IPSec parameters, and — the part a router-only background misses — the security-policy rules that separately permit the tunnel's own negotiation traffic and the private traffic it protects.

By the AtlasCommTech engineering team — 13 years of carrier & enterprise network deployments · Updated July 2026

Why Security Policy and IPSec Have to Be Configured Together

On a firewall, the security policy decides whether the tunnel's own negotiation traffic — and the traffic it protects — is even allowed to reach IPSec in the first place.

On a router, IPSec is largely self-contained: point the traffic at an ACL, negotiate, done. A firewall adds a layer in the way by design — every packet, including the IKE negotiation packets and the ESP-encapsulated payload itself, still has to clear the security-policy engine and its zone-to-zone rules before IPSec ever gets a chance to process it. That means an IPSec configuration that would work fine on a router — proposal, peer, policy, ACL, all correct — can sit there fully configured on a firewall and still refuse to pass a single packet, because the security policy denied it before IPSec had anything to do.

This note is written for the firewall side specifically: configuring security zones, security-policy rules and IPSec VPN together on a Huawei USG so both layers agree with each other. If you're building the tunnel between a Huawei AR router and a different vendor's firewall instead, see our Huawei-to-Fortinet interop configuration guide; if a tunnel is already up but something's still wrong, see our IPSec tunnel troubleshooting flowchart — both of those are written from the router side of this exact problem, not the firewall side covered here.

Topology, Zones and Addressing

Two firewalls, two private LANs, one IPSec tunnel across the internet — plus the zone map that decides whether any of it is actually allowed to happen.

Trust Zone · priority 85 LAN 10.1.1.0/24 GE1/0/0 · 10.1.1.1/24 FW1 Local Zone Untrust Zone · priority 5 GE1/0/1 · 1.1.1.1/24 IPSec Tunnel (ESP) Internet FW2 (remote site) Untrust · 2.1.1.1/24 Trust · LAN 10.1.2.0/24

Diagram labels are kept in English for engineering clarity.

Addressing

ItemValue (this example)
FW1 trust interface — GigabitEthernet1/0/010.1.1.1/24
FW1 untrust (public) interface — GigabitEthernet1/0/11.1.1.1/24
FW2 untrust (public) interface — the tunnel peer2.1.1.1/24
Protected subnet behind FW110.1.1.0/24
Protected subnet behind FW210.1.2.0/24

Step-by-Step Configuration

Assign the interfaces to zones, configure IKE and IPSec, apply the policy — then, the step a router doesn't need, write the security-policy rules for both the tunnel's own traffic and the traffic it protects.

  1. Add each interface to its security zone — the LAN-facing interface into trust, the internet-facing interface into untrust.
  2. Configure an IKE proposal — authentication method, authentication algorithm, encryption algorithm, DH group, PRF algorithm — and an IKE peer referencing it, with the pre-shared key and the peer's public address.
  3. Configure an IPSec proposal (ESP algorithms) and an ACL that defines the protected traffic — this firewall's private subnet as source, the remote private subnet as destination.
  4. Configure an IPSec policy referencing the ACL, the IKE peer and the IPSec proposal, then apply it to the untrust-facing interface.
  5. Configure a route so return traffic actually has a path back through the tunnel.
#
firewall zone trust
 set priority 85
 add interface GigabitEthernet1/0/0
#
firewall zone untrust
 set priority 5
 add interface GigabitEthernet1/0/1
#
ike proposal 10
 authentication-method pre-shared-key
 authentication-algorithm sha2-256
 encryption-algorithm aes-256
 dh group14
 prf hmac-sha2-256
#
ike peer huawei
 ike-proposal 10
 pre-shared-key cipher <same-key-on-both-ends>
 remote-address 2.1.1.1
#
ipsec proposal p1
 esp authentication-algorithm sha2-256
 esp encryption-algorithm aes-256
#
acl number 3100
 rule 5 permit ip source 10.1.1.0 0.0.0.255 destination 10.1.2.0 0.0.0.255
#
ipsec policy policy1 10 isakmp
 security acl 3100
 ike-peer huawei
 proposal p1
#
interface GigabitEthernet1/0/0
 ip address 10.1.1.1 255.255.255.0
#
interface GigabitEthernet1/0/1
 ip address 1.1.1.1 255.255.255.0
 ipsec policy policy1
#
ip route-static 0.0.0.0 0.0.0.0 1.1.1.254
#

Security-Policy Rules: Permitting the Tunnel and the Traffic It Protects

This is the part a router-only IPSec background misses entirely — two separate pairs of rules, not one, and neither is optional.

  1. Permit the IKE/ESP control traffic itself — the negotiation and the encrypted payload as the device sees it — with a rule pair between the local zone and the untrust zone. This traffic is destined to the firewall's own public address, so it lives in the local zone, not trust or untrust.
  2. Separately, permit the actual private traffic being protected — the real source and destination subnets — with a rule pair between the trust zone and the untrust zone. The IPSec ACL only decides what gets encrypted; it has no say over whether the security-policy engine lets that traffic through in the first place.
  3. Keep both rule pairs specific (explicit source-zone and destination-zone, explicit addresses) rather than relying on a single broad permit rule — a broad rule can hide exactly which traffic is actually being allowed, and makes the hit counts on display security-policy rule useless for troubleshooting later.
security-policy
 rule name ike-esp-out
  source-zone local
  destination-zone untrust
  source-address 1.1.1.1 mask 255.255.255.255
  destination-address 2.1.1.1 mask 255.255.255.255
  action permit
 rule name ike-esp-in
  source-zone untrust
  destination-zone local
  source-address 2.1.1.1 mask 255.255.255.255
  destination-address 1.1.1.1 mask 255.255.255.255
  action permit
 rule name private-out
  source-zone trust
  destination-zone untrust
  source-address 10.1.1.0 mask 255.255.255.0
  destination-address 10.1.2.0 mask 255.255.255.0
  action permit
 rule name private-in
  source-zone untrust
  destination-zone trust
  source-address 10.1.2.0 mask 255.255.255.0
  destination-address 10.1.1.0 mask 255.255.255.0
  action permit

This exact rule pattern — one pair for the tunnel's own IKE/ESP traffic in the local zone, one pair for the private traffic in trust/untrust — comes directly from a real fault case where the tunnel showed as established on both ends, yet the two private LANs still couldn't reach each other, because only the first pair had been configured.

5 Configuration Gotchas

The ones that turn a working IPSec configuration into a tunnel that negotiates fine and still doesn't pass a single packet.

1. The Security Policy Must Permit the Tunnel's Own Negotiation Traffic, Not Just the Private Traffic It Protects

SYMPTOMdisplay ike sa shows the IKE SA as established on both firewalls, but nothing ever seems to negotiate, or negotiation restarts constantly.

CAUSEThe IKE negotiation packets (UDP 500/4500) and the ESP-protocol packets themselves have to reach the firewall and be permitted, exactly like any other traffic destined to the device. If the security policy doesn't explicitly permit UDP 500/4500 and AH/ESP protocol traffic to and from the firewall's own public address, the tunnel has no path to negotiate over in the first place.

FIXConfigure a dedicated security-policy rule pair permitting UDP 500/4500 and AH/ESP protocol traffic between the firewall's own address and the peer's — this is separate from, and in addition to, the rule that permits the private traffic itself.

2. The Protected Private Traffic Needs Its Own Security-Policy Rule Too — the IPSec ACL Isn't a Substitute

SYMPTOMdisplay ike sa shows the tunnel as fully established on both ends, but hosts on the two private LANs still can't reach each other.

CAUSEThe IPSec ACL only defines which traffic gets encrypted and sent into the tunnel — it says nothing about whether the security-policy engine actually permits that traffic across zones. Without a separate security-policy rule permitting the private subnets between the trust and untrust zones, the traffic never gets to the point where IPSec would encrypt it.

FIXConfigure the trust-to-untrust and untrust-to-trust security-policy rule pair for the real private subnets, in addition to the IPSec ACL — the two serve different purposes and neither one covers for the other.

3. IKE/ESP Traffic to the Firewall Itself Lives in the Local Zone, Not the Interface's Usual Zone

SYMPTOMA security-policy rule was written for untrust-to-trust or trust-to-untrust to cover the tunnel traffic, and it still doesn't work, even though the addresses look correct.

CAUSETraffic destined to the firewall's own IP address — which is exactly what IKE negotiation and the terminating end of ESP are — is evaluated against the local zone, regardless of which physical interface or zone it arrived on. A rule written for trust or untrust as the destination zone will never match this traffic.

FIXWrite the rule pair for the tunnel's own traffic with local as the zone on whichever side is this device, and confirm it in display firewall session table verbose — a working IKE session shows Zone: local --> untrust (or the reverse), not trust --> untrust.

<FW1> display firewall session table verbose
udp  VPN: public --> public  ID: a68f5bd4603f01f756c5ab54663
Zone: local --> untrust  TTL: 00:02:00  Left: 00:01:58
1.1.1.1:500 --> 2.1.1.1:500  PolicyName: ike-esp-out

4. Without an Explicit ike-proposal Reference, Main Mode and Aggressive Mode Behave Differently

SYMPTOMPhase 1 negotiates successfully in one exchange mode during testing, then fails once the peer's configuration changes slightly, or once switched to a different exchange mode.

CAUSEAs the initiator, if the ike peer has an ike-proposal explicitly referenced, that exact proposal is sent for negotiation. If it isn't referenced, main mode sends every locally configured IKE proposal for the peer to choose from, while aggressive mode sends only the default proposal — two different behaviors from the same missing configuration line, depending on which exchange mode is active.

FIXAlways reference an explicit ike-proposal under the ike peer rather than relying on exchange-mode-dependent defaults, so the same set of parameters is offered regardless of which mode ends up being used.

ike peer huawei
 ike-proposal 10
 remote-address 2.1.1.1

5. The IPSec ACL and the Security-Policy Addresses Have to Describe the Same Traffic, Not Just Overlap

SYMPTOMSome traffic between the two sites goes through the tunnel encrypted as expected; other traffic between what looks like the same two subnets is dropped, or goes out unencrypted.

CAUSEThe IPSec ACL and the security-policy rule addresses were configured at different times, by different people, or copied from different examples, and their subnet ranges no longer describe exactly the same traffic. Traffic that matches the security policy but falls outside the IPSec ACL's range never gets encrypted; traffic that matches the ACL but falls outside the security-policy range never gets there at all.

FIXKeep the IPSec ACL's permit rule and the security-policy rule's source/destination addresses defined from the same source of truth, and re-verify both together any time either one changes — not just the one that was edited.

Related solution designs

How to Confirm It's Actually Working

An established IKE SA is necessary but not sufficient — confirm the security-policy rules are the ones actually being hit, not just present.

  1. Run display ike sa on both firewalls and confirm both Phase 1 and Phase 2 show as established (the RD|ST|A flags).
  2. Run display firewall session table verbose and find the IKE/ESP session — confirm the Zone reads local on this device's side, and that PolicyName shows the dedicated rule you configured, not default.
  3. Run display current-configuration configuration policy-security and re-confirm both rule pairs are present, in a sensible order, with the addresses you expect.
  4. Ping across the tunnel from an actual host on each private subnet, not just from the firewall itself — a firewall-originated ping can succeed through a path a real host's traffic doesn't take.
<FW1> display ike sa
IKE SA information :
   Conn-ID    Peer             VPN              Flag(s)     Phase
  ---------------------------------------------------------------
   151003222  2.1.1.1:500                       RD|ST|A     v1:2
   151003215  2.1.1.1:500                       RD|ST|A     v1:1
  Number of IKE SA : 2

<FW1> display firewall session table verbose
udp  VPN: public --> public  ID: a68f5bd4603f01f756c5ab54663
Zone: local --> untrust  TTL: 00:02:00  Left: 00:01:58
1.1.1.1:500 --> 2.1.1.1:500  PolicyName: ike-esp-out

<FW1> display current-configuration configuration policy-security
security-policy
 rule name ike-esp-out
  source-zone local
  destination-zone untrust
  action permit
 rule name private-out
  source-zone trust
  destination-zone untrust
  action permit

Honest Limits of This Note

Honest Limits of This Note

This note is based on one worked configuration: two Huawei USG-series firewalls, ACL-based IKEv1 IPSec, one protected subnet pair each side, security-policy rules covering the tunnel and the private traffic. It doesn't cover IKEv2-specific configuration nuances, VTI (route-based) IPSec on a firewall, NAT coexisting with this same IPSec policy on the same interface, virtual-system (vsys) specific policy separation, or high-availability/dual-active firewall pairs — those each change enough of the configuration to need their own treatment.

Five Questions Worth Having an Answer For

Pulled from the same configuration cases this note is built on.

Does the firewall need a separate security-policy rule for the IKE/ESP traffic itself, in addition to the rule for the protected traffic?

Yes, always both. The IKE/ESP rule permits the tunnel's own negotiation and encrypted payload to reach the device (local zone); the private-traffic rule permits the actual business traffic to cross from trust to untrust so IPSec has something to encrypt in the first place. Either one missing produces a tunnel that looks fine in display ike sa and still doesn't do anything useful.

What zone does the IKE/IPSec traffic actually belong to on this firewall?

Local — because it's destined to the firewall's own public IP address, not routed through it. This is true regardless of which physical interface or which zone that interface was assigned to; a rule written with trust or untrust as the destination zone for this traffic will never match it.

If I already have a broad default action permit configured, do I still need the specific IPSec-related security-policy rules?

Technically the traffic would pass either way, but a broad default permit is not the production-safe posture this note assumes, and it makes troubleshooting far harder later — display security-policy rule's hit counts become meaningless when everything matches one catch-all rule. Configure the specific rule pairs regardless, and move to default action deny once they're confirmed working.

What's actually different about configuring IPSec on this firewall versus on a Huawei AR router?

The IKE and IPSec parameters themselves — proposal, peer, policy, ACL — are essentially the same concepts on both platforms. What a router doesn't have is the security-policy layer sitting in front of IPSec: on a router, once the ACL and interface configuration are correct, traffic reaches IPSec directly. On this firewall, the security policy has to separately permit both the tunnel's own traffic and the protected traffic before IPSec gets a chance to act on either. See our Huawei-to-Fortinet configuration guide and our IPSec tunnel troubleshooting flowchart for the router-side version of this same tunnel logic.

Can NAT and this IPSec tunnel coexist on the same untrust interface?

Yes, but the same rule that governs routers applies here too: NAT is evaluated before IPSec in the forwarding order, so the NAT policy's matching ACL must explicitly exclude the traffic destined for the tunnel's protected subnets, or that traffic gets translated and sent to the internet instead of encrypted into the tunnel — with no error to point at except a stuck encryption counter.

Combining firewall policy with an IPSec tunnel?

Tell us your zone layout and which subnets need to cross the tunnel, and we'll help you get the security-policy rules right the first time.

WhatsApp an engineer →

Related Reading