Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a firewall/router (not doing NAT).

I've googled and seen conflicting answers. It seems UDP 500 is the common one. But the others are confusing. 1701, 4500.

And some say I need to also allow gre 50, or 47, or 50 & 51.

Ok, which ports are the correct ones for IPSec/L2TP to work in a routed environment without NAT? i.e. I want to use the built in windows client to connect to a VPN behind this router/firewall.

Perhaps a good answer here is to specify which ports to open for different situations. I think this would be useful for many people.

share|improve this question
    
Am I right if it's udp 500,1701 and gre 50? –  Matt Nov 22 '12 at 23:01

2 Answers 2

up vote 4 down vote accepted

Here are the ports and protocols:

  • Protocol: UDP, port 500 (for IKE, to manage encryption keys)
  • Protocol: UDP, port 4500 (for IPSEC NAT-Traversal mode)
  • Protocol: ESP, value 50 (for IPSEC)
  • Protocol: AH, value 51 (for IPSEC)

Also, Port 1701 is used by the L2TP Server, but connections should not be allowed inbound to it from outside. There is a special firewall rule to allow only IPSEC secured traffic inbound on this port.

If using IPTABLES, and your L2TP server sits directly on the internet, then the rules you need are:

iptables -A INPUT -i $EXT_NIC -p udp --dport 500 -j ACCEPT
iptables -A INPUT -i $EXT_NIC -p udp --dport 4500 -j ACCEPT
iptables -A INPUT -i $EXT_NIC -p 50 -j ACCEPT
iptables -A INPUT -i $EXT_NIC -p 51 -j ACCEPT
iptables -A INPUT -i $EXT_NIC -p udp -m policy --dir in --pol ipsec -m udp --dport 1701 -j ACCEPT

Where $EXT_NIC is your external network interface card name, e.g. ppp0.

share|improve this answer
    
I found I don't need ESP & AH as I'm not using IPSEC directly but IPSEC over L2TP with NAT. So I am able to get away with ports 500,4500,1701. Interesting comment about the special rule for 1701. I'll have to try that as soon as I figure out how to configure it with Mikrotik. –  Matt Sep 18 at 23:08

Ipsec needs UDP port 500 + ip protocol 50 and 51 - but you can use NAt-T instead, which needs UDP port 4500. On the other hand L2TP uses udp port 1701. If you trying to pass ipsec traffic through a "regular" Wi-Fi router and there is no such option as IPSec pass-through, I recommend opening port 500 and 4500. At least that is how it works on mine. Hope this helps.

share|improve this answer
    
Thanks, I will give that a try. –  Matt Nov 23 '12 at 1:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.