遊戲連線站
VPN

IPsec Port: Which Ports and Protocols Does IPsec Use?

By 杭予安 · · 7 min
IPsec Port: Which Ports and Protocols Does IPsec Use?

Learn which ports IPsec uses, how UDP 500 and 4500 support VPN connections, and what to allow through a firewall.

IPsec does not have a single “IPsec port.” For a typical IPsec VPN, allow UDP port 500 for IKE negotiation and UDP port 4500 when NAT traversal is needed. The encrypted data is commonly carried by ESP, which uses IP protocol number 50, not a TCP or UDP port. Some configurations may also use AH, IP protocol number 51.

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

Port or protocolTypeMain roleNAT traversalFirewall action
UDP 500UDP portIKE negotiationUsed to start negotiationAllow when using IPsec
UDP 4500UDP portIKE and NAT-T trafficCarries encapsulated IPsec trafficAllow when NAT-T is needed
ESPIP protocolCarries encrypted dataEncapsulated in UDP 4500 with NAT-TAllow ESP if not encapsulated
AHIP protocolAuthentication and integrityNot supported through typical NATAllow AH only when required
IKEKey-exchange protocolNegotiates security associationsUses UDP 500 or UDP 4500Permit its required UDP traffic
NAT-TEncapsulation methodHelps IPsec cross NAT devicesUses UDP 4500Permit UDP 4500
IPsecSecurity protocol suiteProtects IP trafficUses NAT-T when neededPermit required ports and protocols

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. It authenticates and encrypts packets at the network layer, often as the foundation for site-to-site or remote-access VPNs.

The port or protocol needed depends on how the VPN is configured:

Traffic Number Purpose
IKE over UDP UDP 500 Establishes and negotiates the IPsec security association
NAT traversal (NAT-T) UDP 4500 Carries IKE and encapsulated ESP through NAT devices
ESP IP protocol 50 Carries encrypted IPsec data
AH IP protocol 51 Provides authentication and integrity without encryption

UDP 500 and UDP 4500 are transport-layer ports. ESP and AH are IP protocols, identified by protocol numbers in the IP header. That distinction matters when configuring a firewall: a rule for “port 50” is not equivalent to permitting ESP.

IPsec Port: Which Ports and Protocols Does IPsec Use?: Checklist

What UDP 500 does

Internet Key Exchange (IKE) negotiates how two IPsec peers will communicate. The peers use it to authenticate one another, agree on cryptographic parameters, and establish security associations, the settings that govern protected traffic. FortiGate VPN: How It Works, Setup Options, and What to Know

IKE commonly begins over UDP 500. This port is used by both IKEv1 and IKEv2 in typical deployments. The negotiation itself does not carry all VPN user traffic. It sets up the parameters that allow protected traffic to flow.

If UDP 500 is blocked between the peers, they may be unable to establish the tunnel. A connection can also fail if authentication, encryption settings, or other network requirements do not match.

What UDP 4500 does

Network Address Translation (NAT) changes IP addresses or ports as traffic passes through a router or gateway. This can interfere with native ESP traffic because ESP does not use TCP or UDP ports, leaving NAT devices without the port information they often expect when tracking connections.

NAT Traversal, usually abbreviated NAT-T, addresses this by encapsulating IPsec traffic in UDP. When NAT is detected, the peers typically use UDP 4500 to carry both IKE messages and encapsulated ESP data. Cisco AnyConnect VPN: How to Install, Connect, and Troubleshoot

In practical terms:

  • If the IPsec peers are not behind NAT, UDP 500 and native ESP may be sufficient.
  • If a NAT device is between the peers, UDP 4500 is commonly required.
  • Many administrators allow both UDP 500 and UDP 4500 to support negotiation and NAT-T.

Exact behavior depends on the VPN software, gateway, and configuration. Check the product documentation when setting up a particular client or appliance.

UDP 500 and UDP 4500 compared

FeatureUDP 500UDP 4500
Primary useIKE negotiationIKE and NAT-T traffic
Used at connection startYesWhen NAT traversal is used
Carries encrypted IPsec dataNo, not by itselfYes, when IPsec is encapsulated
NAT traversal roleStarts negotiationCarries traffic through NAT
Firewall requirementAllow for IPsec negotiationAllow for NAT-T
Works alongside ESPNegotiates its useEncapsulates ESP when needed
Typical issue if blockedTunnel negotiation may failNAT-T traffic may fail
Port or protocolUDP portUDP port

Compiled November 2026; check the provider's site for current details. VPN Country Changer Free: How to Change Your Virtual Location Safely

ESP and AH are not ports

ESP, or Encapsulating Security Payload, is the IPsec protocol most commonly used to protect VPN traffic. It can provide encryption, integrity, and authentication. ESP is identified by IP protocol number 50. It does not use a TCP or UDP port.

AH, or Authentication Header, is identified by IP protocol number 51. It provides integrity and authentication but not encryption. AH is less common in many modern VPN deployments, partly because its handling of IP headers can conflict with NAT.

A firewall rule should therefore distinguish between transport ports and IP protocols. Depending on the firewall, you may need to create a rule that permits ESP by protocol number, rather than entering “port 50.” If NAT-T is in use, ESP is encapsulated in UDP 4500, so the relevant firewall rule is typically for that UDP port.

IPsec Port: Which Ports and Protocols Does IPsec Use?: Key points

Firewall and network setup

For a standard IPsec VPN, configure access based on the connection path and the VPN’s requirements. A common starting point is to permit inbound and outbound UDP 500 and UDP 4500 between the VPN peers. If the setup uses native ESP without NAT-T, also permit IP protocol 50. Tuxler VPN Extension: How It Works, Setup, and What to Know

Before changing firewall rules, identify:

  • The public IP addresses of the VPN peers.
  • Whether either peer is behind NAT.
  • Whether the VPN uses IKEv1 or IKEv2 and whether NAT-T is enabled.
  • Whether the firewall supports rules for IP protocols as well as TCP and UDP ports.
  • Whether any cloud security groups, host firewalls, or upstream networks filter the traffic.

Use the narrowest rules that work, for example, allow the required traffic only between the known VPN peer addresses rather than opening it broadly to the internet. Avoid assuming that permitting TCP or UDP port 50 will allow ESP. It will not.

Network setup options for IPsec

Network conditionAllow UDP 500Allow UDP 4500Allow ESPAllow AH
IPsec without NATYesNot usually neededYesOnly if used
IPsec across NATYesYesUsually carried inside UDP 4500Typically not suitable
NAT-T requiredYesYesEncapsulated in UDP 4500No
Firewall blocks UDP 500Permit itPermit if NAT-T is usedPermit if not encapsulatedPermit only if used
Firewall blocks UDP 4500Permit itPermit it for NAT-TMay work without NATNot a substitute
ESP blocked by firewallPermit UDP 500Permit UDP 4500 if using NAT-TPermit ESP or use NAT-TNot a replacement for ESP
AH requiredPermit if IKE is usedAs needed for NAT-TAs configuredPermit AH protocol
Troubleshooting a failed tunnelCheck reachabilityCheck when NAT is presentCheck if not encapsulatedCheck only when configured

Compiled November 2026; check the provider's site for current details. Free VPN for PC to Change Location: Safe and Practical Options

Common IPsec connectivity problems

A tunnel that does not establish may be blocked from reaching UDP 500 or UDP 4500. A tunnel that establishes but cannot pass data may have ESP or NAT-T traffic blocked, mismatched routing, or incompatible security policies.

Check firewall logs and VPN logs on both ends. Confirm that the peers agree on authentication methods, encryption algorithms, lifetimes, and traffic selectors. If NAT is present, verify that NAT-T is supported and that UDP 4500 can pass through the relevant routers and firewalls.

Also consider the type of VPN. Some services use IPsec only for part of their connection process, while others encapsulate it inside another protocol or require additional vendor-specific settings. The provider’s configuration guide is the best source for exceptions.

Recommendation

For most IPsec VPNs, allow UDP 500 and UDP 4500 between the peers, then verify whether native ESP (IP protocol 50) is required for the specific setup. Treat ESP and AH as IP protocols, not port numbers, and restrict firewall access to the necessary endpoints. IPsec VPN: How It Works, Benefits, and When to Use It

© 2026 Fernhollow Play Media · Fernhollow Play Media Ltd.