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.
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 protocol | Type | Main role | NAT traversal | Firewall action |
|---|---|---|---|---|
| UDP 500 | UDP port | IKE negotiation | Used to start negotiation | Allow when using IPsec |
| UDP 4500 | UDP port | IKE and NAT-T traffic | Carries encapsulated IPsec traffic | Allow when NAT-T is needed |
| ESP | IP protocol | Carries encrypted data | Encapsulated in UDP 4500 with NAT-T | Allow ESP if not encapsulated |
| AH | IP protocol | Authentication and integrity | Not supported through typical NAT | Allow AH only when required |
| IKE | Key-exchange protocol | Negotiates security associations | Uses UDP 500 or UDP 4500 | Permit its required UDP traffic |
| NAT-T | Encapsulation method | Helps IPsec cross NAT devices | Uses UDP 4500 | Permit UDP 4500 |
| IPsec | Security protocol suite | Protects IP traffic | Uses NAT-T when needed | Permit 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.
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
| Feature | UDP 500 | UDP 4500 |
|---|---|---|
| Primary use | IKE negotiation | IKE and NAT-T traffic |
| Used at connection start | Yes | When NAT traversal is used |
| Carries encrypted IPsec data | No, not by itself | Yes, when IPsec is encapsulated |
| NAT traversal role | Starts negotiation | Carries traffic through NAT |
| Firewall requirement | Allow for IPsec negotiation | Allow for NAT-T |
| Works alongside ESP | Negotiates its use | Encapsulates ESP when needed |
| Typical issue if blocked | Tunnel negotiation may fail | NAT-T traffic may fail |
| Port or protocol | UDP port | UDP 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.
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 condition | Allow UDP 500 | Allow UDP 4500 | Allow ESP | Allow AH |
|---|---|---|---|---|
| IPsec without NAT | Yes | Not usually needed | Yes | Only if used |
| IPsec across NAT | Yes | Yes | Usually carried inside UDP 4500 | Typically not suitable |
| NAT-T required | Yes | Yes | Encapsulated in UDP 4500 | No |
| Firewall blocks UDP 500 | Permit it | Permit if NAT-T is used | Permit if not encapsulated | Permit only if used |
| Firewall blocks UDP 4500 | Permit it | Permit it for NAT-T | May work without NAT | Not a substitute |
| ESP blocked by firewall | Permit UDP 500 | Permit UDP 4500 if using NAT-T | Permit ESP or use NAT-T | Not a replacement for ESP |
| AH required | Permit if IKE is used | As needed for NAT-T | As configured | Permit AH protocol |
| Troubleshooting a failed tunnel | Check reachability | Check when NAT is present | Check if not encapsulated | Check 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
