Port 1701 (L2TP)
Key facts
- Port
- 1701
- Protocols
- UDP
- Range
- Registered port, 1024-49151
- IANA service name
- l2f, l2tp
IANA assigns ports in this range to services on request, under RFC 6335.
About port 1701
Port 1701 is the port of L2TP (Layer 2 Tunneling Protocol), a protocol that creates a tunnel between a computer and a VPN server, or between two sites. According to RFC 2661, L2TP uses the registered UDP port 1701, and RFC 3931 defines the third version of the protocol.
L2TP does not encrypt traffic by itself, so it almost always runs together with IPsec, a combination called L2TP/IPsec. According to RFC 3193, IPsec protects all L2TP packets, so port 1701 only receives traffic that has already passed through the encrypted tunnel. The encrypted connection is set up on port 500, and when there is NAT along the way it moves to port 4500. In the IANA port registry, port 1701 is registered for the l2tp service, and also for the older l2f service.
What port 1701 is used for
- VPN for employees: computers and phones connect to the office network through the L2TP/IPsec client built into the operating system, without installing any software.
- Routers and firewalls: many routers offer a built-in L2TP/IPsec server for remote access.
- Service providers: providers use L2TP to carry customer connections between their network equipment.
Port 1701 in the firewall
On an L2TP/IPsec server, open UDP ports 500 and 4500 and the ESP protocol to the internet, and allow port 1701 only for traffic that arrived through IPsec:
- firewalld:
firewall-cmd --permanent --add-service=ipsec - UFW:
ufw allow 500/udpandufw allow 4500/udp - iptables:
iptables -A INPUT -p udp --dport 1701 -m policy --dir in --pol ipsec -j ACCEPT
The last rule accepts packets on port 1701 only when they arrived encrypted with IPsec. This way, port 1701 is never open to direct connections from the internet.
Risks and security
L2TP on its own carries traffic without encryption, so it is used only as L2TP/IPsec. A few settings keep the connection safe:
- Don't open port 1701 to everyone. Allow it only for traffic that has passed through IPsec.
- When you use a Pre-Shared Key, a secret key set in advance on the server and the clients, choose a long, random key, and prefer certificates.
- Allow only current encryption algorithms, and remove users who no longer need a connection.
- Microsoft has announced that future versions of Windows Server will no longer include remote access over L2TP and PPTP, and recommends moving to IKEv2 or SSTP. For a new setup, choose IKEv2, WireGuard or OpenVPN.
Commands to check and configure
-
ss -ulnp | grep ':1701 'Checks whether an L2TP service is listening on port 1701 on the server, and which process it is (requires root privileges).
-
swanctl --list-sasShows the active IPsec connections in strongSwan, which carry the L2TP traffic.
-
tcpdump -ni any udp port 1701 or udp port 500 or udp port 4500Shows the L2TP and IPsec traffic, to check that the connection reaches the server (requires root privileges).
-
firewall-cmd --permanent --add-service=ipsecOpens ports 500 and 4500 in firewalld and allows the ESP protocol. Then run firewall-cmd --reload.
-
iptables -A INPUT -p udp --dport 1701 -m policy --dir in --pol ipsec -j ACCEPTAllows port 1701 only for packets that arrived through IPsec (iptables).
-
Get-VpnConnectionShows the VPN connections set up on a Windows computer in PowerShell, including the tunnel type (TunnelType).
-
Set-VpnConnection -Name "Office" -TunnelType Ikev2Switches the VPN connection named Office to IKEv2 in PowerShell, when the server supports it.
Port 1701 in the IANA registry
| Port | Protocol | Service | IANA registry description |
|---|---|---|---|
| 1701 | TCP | l2f | l2f |
| 1701 | TCP | l2tp | l2tp |
| 1701 | UDP | l2f | l2f |
| 1701 | UDP | l2tp | l2tp |
Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)
Port 1701 FAQ
What's the difference between L2TP and L2TP/IPsec?
L2TP creates the tunnel, but doesn't encrypt what passes through it. With L2TP/IPsec, IPsec encrypts and authenticates all the traffic, and L2TP runs inside the encrypted connection. This is the combination operating systems offer when you choose an L2TP connection.
Which ports do I need to open for L2TP/IPsec?
Why doesn't my L2TP connection work behind a home router?
In most cases, port 4500 is blocked, or the server or the client doesn't support NAT-T, which carries IPsec through routers that perform NAT. Check that ports 500 and 4500 are open on the server, and that NAT-T is enabled on both sides.
What should I replace L2TP with?
IKEv2 is supported by operating systems without any installation and uses the same ports, 500 and 4500. WireGuard and OpenVPN are simple to set up on a Linux server and also work well on phones. The WireGuard commands and OpenVPN commands pages have commands for setup and testing.