VPN

IPsec Port Guide: Ports and Protocols You Need to Know

韩知予··7 min
IPsec Port Guide: Ports and Protocols You Need to Know

Learn which ports and protocols IPsec uses, how NAT changes traffic, and what to allow through firewalls.

IPsec does not use a single “IPsec port.” For Internet Key Exchange (IKE), it uses UDP port 500. When NAT Traversal is needed, it typically uses UDP port 4500. The encrypted data itself is usually carried by ESP, IP protocol 50, which is a protocol number rather than a TCP or UDP port. Some configurations use AH, IP protocol 51, but it is less common and generally does not work through NAT.

NordVPN — fast, secure VPN

Editor's pick: NordVPN — fast, secure VPN — Strong encryption, a no-logs policy and apps for every device. 30-day money-back guarantee. Get NordVPN →

IPsec ports and protocols at a glance

ItemTypeIP protocol or portMain purposeFirewall handling
IKEKey-management protocolUDP 500Negotiates security associationsAllow inbound and outbound
NAT-TEncapsulation for IPsecUDP 4500Carries IPsec traffic through NATAllow inbound and outbound
ESPIP protocolIP protocol 50Encrypts and protects IPsec packetsAllow ESP if not using NAT-T
AHIP protocolIP protocol 51Provides authentication and integrityAllow AH if used
IKEv2Key-management protocolUsually UDP 500 and 4500Sets up and manages IPsec tunnelsAllow both UDP ports
NAT deviceNetwork equipmentNot a portMay require IPsec traffic encapsulationCheck NAT-T support
VPN gatewayNetwork endpointDepends on configurationTerminates the IPsec tunnelMatch rules to the chosen setup

Compiled November 2026; check the provider's site for current details.

IPsec ports and protocols at a glance

IPsec is a suite of protocols for securing IP traffic. A VPN using IPsec needs both a way to negotiate security settings and a way to carry protected data. These functions use different network traffic, which is why asking for “the IPsec port” can be misleading.

Traffic Port or protocol Purpose
IKE and IKEv2 negotiation UDP 500 Establishes and manages the security association
NAT Traversal (NAT-T) UDP 4500 Carries IKE and encapsulated ESP through NAT
ESP data IP protocol 50 Protects and transports VPN data
AH, if configured IP protocol 51 Provides authentication and integrity without encryption

Ports belong to TCP or UDP. ESP and AH are IP protocols identified by protocol numbers, so they cannot be entered as TCP or UDP ports in a firewall rule.

IPsec Port Guide: Ports and Protocols You Need to Know: Checklist

What UDP 500 does

IKE uses UDP 500 to set up the IPsec connection. The VPN peers exchange proposals, authenticate each other, agree on encryption and integrity settings, and establish the security associations that protect traffic.

IKE may also handle rekeying and other connection-management tasks after the tunnel is active. If UDP 500 is blocked between the peers, they may fail to establish a tunnel or may not be able to restore it after an interruption. VPN Country Changer Free: How to Change Your Virtual Location Safely

Both endpoints need compatible IKE settings, such as authentication methods and cryptographic algorithms. Opening UDP 500 alone does not guarantee a working VPN: the peers must also agree on their configuration, and the necessary data traffic must be allowed.

Why UDP 4500 is used

NAT Traversal, commonly called NAT-T, helps IPsec work when one or both VPN peers are behind a Network Address Translation device. NAT changes packet addresses, which can interfere with IPsec’s handling of protected traffic.

When NAT is detected, peers typically move to UDP 4500. NAT-T encapsulates ESP traffic inside UDP packets so it can pass through the NAT device. IKE traffic may also use UDP 4500 after the peers switch to NAT-T.

This is why many firewall and router guides say to allow both UDP 500 and UDP 4500. In a setup that requires NAT-T, permitting only UDP 500 may allow initial negotiation but still leave the tunnel unable to carry data. Free VPN for PC to Change Location: Safe Options and Limitations

ESP and AH are not ports

ESP, or Encapsulating Security Payload, is usually the protocol that carries encrypted IPsec data. It is IP protocol 50, not “port 50.” A firewall rule for ESP must allow the protocol itself. A TCP or UDP rule with destination port 50 is not equivalent.

AH, or Authentication Header, is IP protocol 51. It provides authentication and integrity but not encryption. AH includes information tied to the original IP header, which makes it a poor fit for traffic passing through NAT. For that reason, AH is uncommon in typical remote-access and site-to-site VPN deployments.

The practical distinction is:

  • Allow UDP 500 for IKE negotiation.
  • Allow UDP 4500 when NAT-T is used or required.
  • Allow ESP (IP protocol 50) if the setup carries ESP directly rather than encapsulating it in UDP.
  • Allow AH (IP protocol 51) only if the VPN specifically uses it.
IPsec Port Guide: Ports and Protocols You Need to Know: Key points

IPsec compared with other VPN protocols The Best Free VPN That Allows You to Change Location

VPN optionKey setup or transportTypical port or protocolNAT traversalMain comparison point
IPsec with IKEIKE negotiates the tunnelUDP 500Supported with NAT-TUses ESP or AH for IPsec traffic
IPsec with NAT-TIKE plus encapsulated IPsecUDP 4500YesHelps IPsec cross NAT devices
OpenVPN over UDPOpenVPN transportConfigurable UDP portSupportedPort can be configured
OpenVPN over TCPOpenVPN transportConfigurable TCP portSupportedUses TCP transport
WireGuardWireGuard transportConfigurable UDP portSupportedUses UDP
L2TP/IPsecL2TP combined with IPsecCommonly UDP 500, 4500 and 1701Supported through IPsec NAT-TRequires rules for both components
PPTPPPTP transportTCP 1723 and GRELimitedUses GRE as well as TCP

Compiled November 2026; check the provider's site for current details.

Firewall rules and common troubleshooting

The precise rules depend on whether the VPN is site-to-site or remote-access, whether NAT is present, and how the VPN gateway is configured. For a common IPsec VPN with NAT-T, allow inbound and outbound UDP 500 and UDP 4500 between the relevant peers. If the connection uses native ESP without NAT-T, permit IP protocol 50 as well.

When configuring a firewall, specify the remote peer’s address where possible rather than exposing the services to every source. On a VPN gateway behind a router, port forwarding may be necessary for UDP 500 and UDP 4500, along with any required handling of ESP. Some routers provide an IPsec passthrough setting instead.

If the tunnel does not connect or pass traffic, check these points: VPN Change Country Free: How to Switch Your Virtual Location

  • Confirm that UDP 500 and, when applicable, UDP 4500 are allowed in both directions.
  • Check whether the path uses NAT and whether both peers support NAT-T.
  • Verify that ESP is allowed if it is not being carried inside UDP 4500.
  • Review VPN logs for IKE negotiation, authentication, or proposal mismatches.
  • Check that the local and remote traffic selectors and routing rules match.
  • Confirm that another firewall, cloud security group, or internet provider is not filtering the traffic.

A connection that establishes but cannot pass data often points to a missing ESP or NAT-T rule, an incorrect route, or mismatched traffic selectors. A connection that never negotiates may instead indicate blocked IKE traffic or incompatible settings.

IPsec compared with other VPN protocols

IPsec’s use of both ports and IP protocols differs from VPN technologies that carry all traffic over a single TCP or UDP port. For example, some VPNs are configured around one transport port, while IPsec may use UDP for negotiation and NAT-T and a separate IP protocol for ESP data.

This distinction matters when creating firewall rules and reviewing network logs. If a firewall interface only offers TCP and UDP port fields, look for a separate option for IP protocols or “IP protocol number.” Otherwise, the rule may not permit native ESP traffic.

Firewall checks for common IPsec symptoms F5_vpn_edge client.exe: What It Is and How to Check It Safely

SymptomCheck firstRelevant trafficWhat to verifyNext step
Tunnel will not startIKE reachabilityUDP 500Both directions are allowedCheck gateway and firewall rules
Tunnel fails behind NATNAT-T reachabilityUDP 4500NAT-T is enabled and allowedConfirm both peers support NAT-T
IKE connects but data failsIPsec data pathESP, IP protocol 50ESP is allowed when used directlyCheck whether NAT-T is carrying the traffic
AH tunnel failsAH handlingAH, IP protocol 51Network permits AHCheck whether AH is required
One-way trafficReturn-path rulesUDP 500, UDP 4500, ESP or AHRules allow traffic in both directionsReview routing and firewall state
Tunnel works on one network onlyNetwork filteringUDP 500, UDP 4500, ESP or AHThe other network permits required trafficCompare firewall policies
Port-based rule misses ESPRule typeIP protocol 50, not a portRule matches the IP protocol numberUse a protocol-aware rule

Compiled November 2026; check the provider's site for current details.

Recommendation

For a typical IPsec VPN, start by allowing UDP 500 and UDP 4500 between the VPN peers, and enable NAT-T if traffic crosses NAT. Permit ESP (IP protocol 50) when the configuration uses native ESP, and allow AH only if it is explicitly required. Follow the VPN vendor’s guidance and limit rules to the necessary peers and directions.