IPsec Port: Which Ports and Protocols Does IPsec Use?

Learn which ports and protocols IPsec uses, how NAT changes connectivity, and what to allow through your firewall.
IPsec does not use a single “IPsec port.” For VPN setup, Internet Key Exchange (IKE) commonly uses UDP port 500. If Network Address Translation (NAT) is involved, IPsec generally switches to UDP port 4500 for NAT Traversal (NAT-T). Encrypted data may then travel inside ESP, which is IP protocol 50, not a TCP or UDP port. The exact traffic to allow depends on the VPN configuration and whether NAT is present.
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
IPsec is a suite of protocols for securing IP traffic. It establishes keys and security associations, then protects data packets. Different parts of that process use different ports or IP protocols.
| Traffic | Port or protocol | Purpose |
|---|---|---|
| IKE and IKEv2 | UDP 500 | Negotiates security settings and establishes keys |
| NAT Traversal (NAT-T) | UDP 4500 | Carries IKE and encapsulated IPsec traffic through NAT |
| ESP | IP protocol 50 | Protects and transports IPsec data |
| AH, if used | IP protocol 51 | Provides authentication and integrity without encryption |
Ports belong to transport protocols such as TCP and UDP. ESP and AH are IP protocols, identified directly in the IP header. Therefore, a firewall rule for “port 50” is not the same as permitting ESP.
What UDP 500 does
UDP port 500 is the standard port for IKE, the protocol that negotiates an IPsec connection. IKE authenticates the peers, agrees on cryptographic settings, and creates the security associations used to protect traffic.
Both IKEv1 and IKEv2 commonly use UDP 500 for this initial exchange. If a firewall blocks UDP 500, the peers may not be able to establish the VPN at all. VPN Country Changer Free: How to Change Your Virtual Location Safely
Allowing UDP 500 does not, by itself, guarantee that protected data can pass. The VPN also needs a suitable data path, such as ESP or NAT-T.
Why UDP 4500 is used
NAT lets multiple devices share public IP addresses, but it can interfere with IPsec’s native ESP traffic. ESP does not use TCP or UDP ports, so some NAT devices cannot track or translate it in the same way they handle ordinary port-based connections.
NAT Traversal addresses this by encapsulating IPsec traffic in UDP packets, usually using port 4500. When NAT is detected during setup, the VPN typically moves from UDP 500 to UDP 4500 for the relevant traffic.
In practical terms: Free VPN for PC to Change Location: What to Know Before You Connect
- Permit UDP 500 for IKE negotiation.
- Permit UDP 4500 when NAT-T is needed or enabled.
- Do not assume UDP 4500 is required for every IPsec connection. It depends on the network and VPN implementation.
Many VPN clients and gateways support NAT-T automatically. If a connection works on a direct network but fails behind a home router, hotel Wi-Fi, or another NAT device, UDP 4500 is one of the first settings to check.
ESP and AH are not ports
ESP, or Encapsulating Security Payload, is IP protocol 50. It is widely used to encrypt and protect IPsec traffic. Because ESP is not TCP or UDP, it does not have a “port 50.”
This distinction matters when configuring firewalls, routers, and cloud security rules. A rule that allows TCP 50 or UDP 50 does not necessarily permit ESP. The rule must allow the ESP IP protocol itself.
AH, or Authentication Header, is IP protocol 51. It provides integrity and authentication but not encryption. AH is less commonly used in modern VPN deployments, and it can also be problematic with NAT because it authenticates parts of the IP header that NAT changes. Free VPN That Allows You to Change Location: What to Know
| Requirement | Correct firewall concept |
|---|---|
| IKE negotiation | UDP destination port 500 |
| NAT-T traffic | UDP destination port 4500 |
| Native ESP traffic | IP protocol 50 |
| AH traffic, if configured | IP protocol 51 |
If a firewall offers protocol-based rules, select ESP rather than entering a TCP or UDP port. If the firewall only supports port-based rules, consult its documentation or use NAT-T if supported by both VPN endpoints.
What to allow through a firewall
The right rule set depends on whether you are configuring a VPN client, a VPN gateway, or a network firewall between two IPsec peers. It also depends on whether the connection uses native ESP or NAT-T.
For a typical IPsec VPN that supports NAT-T, the commonly needed inbound or outbound traffic is:
- UDP 500 for IKE.
- UDP 4500 for NAT-T.
- ESP (IP protocol 50) if native ESP is used and the network requires it.
Allow traffic only where needed. For a site-to-site VPN, that may mean permitting the protocols between the public addresses of the two gateways rather than exposing them broadly. For a remote-access VPN, follow the VPN provider’s or organization’s configuration instructions. VPN Change Country Free: How to Choose and Use a Free VPN
Firewalls are stateful in many networks, so an outbound connection may allow its replies automatically. However, gateway rules, cloud security groups, and upstream firewalls can behave differently. Check every network boundary along the route, including the client device, local router, cloud network, and VPN gateway.
Troubleshooting IPsec port issues
If an IPsec VPN will not connect, use logs from both ends to identify which part of the exchange is failing. A timeout before IKE negotiation often points to UDP 500 being blocked or the peer address being incorrect. A connection that starts but fails when NAT is present may involve UDP 4500 or NAT-T settings.
Useful checks include:
- Confirm both peers use compatible IKE versions and authentication settings.
- Verify UDP 500 and, where applicable, UDP 4500 are allowed in both directions as required.
- Check whether the firewall supports IP protocol 50 if native ESP is in use.
- Confirm that the VPN gateway’s public address and NAT rules are correct.
- Review logs for rejected packets, failed negotiations, or mismatched security policies.
Avoid opening unrelated ports or treating “port 50” as a substitute for ESP. If the VPN uses a nonstandard configuration, the administrator or vendor documentation should specify the required protocols and ports. What Is f5_vpn_edge client.exe? Safety, Purpose, and Troubleshooting
Recommendation
For most IPsec VPN setups, start by allowing UDP 500 for IKE and UDP 4500 for NAT-T. Permit ESP (IP protocol 50) only when the configuration uses native ESP and the network needs it. Check the VPN documentation and firewall logs, and scope rules to the relevant peers whenever possible.
