Layer Two Tunneling Protocol (L2TP) combined with IPsec provides a secure VPN solution suitable for GOOSE VPN users needing bandwidth management capabilities. L2TP itself does not provide encryption; IPsec adds this crucial layer. This configuration allows for granular control over traffic shaping and prioritization, essential for managing bandwidth-intensive applications or users on a GOOSE VPN. The advantage of L2TP/IPsec lies in its relatively wide support across different operating systems and network devices, making it a versatile choice. However, it is more complex to configure than simpler protocols like PPTP or OpenVPN, and can suffer from performance overhead due to the double encapsulation.
Configuration involves both the GOOSE VPN server and the client. On the server side, a common setup uses xl2tpd for L2TP and strongSwan for IPsec. The xl2tpd.conf file defines the L2TP parameters:
[global]
listen-addr = 10.0.0.1 ; GOOSE VPN server IP
port = 1701
[lac default]
lns = 10.0.0.1 ; GOOSE VPN server IP
redial = yes
redial timeout = 5
max redials = 5
length bit = yes
The ipsec.conf file handles IPsec settings:
conn L2TP-PSK
authby=secret
pfs=no
rekey=no
keyingtries=%forever
ikelifetime=8h
keylife=1h
type=transport
left=10.0.0.1 ; GOOSE VPN server IP
leftprotoport=17/1701
right=%any
rightprotoport=17/%any
Bandwidth management is implemented using traffic control (tc) commands in Linux. For example, to limit the upload bandwidth for L2TP clients to 1 Mbps:
tc qdisc add dev eth0 root handle 1: htb default 12
tc class add dev eth0 parent 1: classid 1:1 htb rate 1000kbps burst 15k
tc class add dev eth0 parent 1:1 classid 1:12 htb rate 1000kbps burst 15k
tc qdisc add dev eth0 parent 1:12 sfq perturb 10
tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip sport 1701 0xffff flowid 1:12
Replace eth0 with the appropriate network interface. Similar rules can be applied to control download bandwidth, using tc qdisc add dev ppp0 root ... where ppp0 represents the L2TP interface.
L2TP/IPsec, when used with GOOSE VPN, requires careful routing configuration. The server must forward traffic correctly between the L2TP interface (e.g., ppp0) and the external network interface. Enable IP forwarding in sysctl.conf: net.ipv4.ip_forward = 1. Use iptables for NAT:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i ppp0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -o ppp0 -j ACCEPT
DNS configuration is also crucial. Clients should be configured to use the GOOSE VPN server's DNS or a public DNS server (e.g., 8.8.8.8) to prevent DNS leaks. This can be configured in the /etc/ppp/options.xl2tpd file on the server or pushed to the client via PPP options.
The firewall needs to allow IPsec and L2TP traffic. Essential iptables rules include:
iptables -A INPUT -p udp --dport 500 -j ACCEPT ; ISAKMP
iptables -A INPUT -p udp --dport 4500 -j ACCEPT ; NAT-T
iptables -A INPUT -p udp --dport 1701 -j ACCEPT ; L2TP
iptables -A INPUT -p esp -j ACCEPT ; ESP
These rules allow the necessary UDP ports for IPsec key exchange and L2TP, as well as the ESP protocol for encrypted data. Ensure these rules are placed before any default deny rules. Further restrict access based on source IP addresses for enhanced security on the GOOSE VPN.
L2TP/IPsec can introduce performance overhead. Optimize MTU (Maximum Transmission Unit) settings to reduce fragmentation. A common MTU value for L2TP/IPsec is 1400 bytes. Adjust the MTU on both the server and client interfaces. Consider using hardware acceleration for IPsec encryption if available, as this can significantly improve throughput. Profile network traffic to identify bottlenecks and adjust traffic shaping rules accordingly. Experiment with different IPsec encryption algorithms to find the best balance between security and performance.
After configuring the GOOSE VPN L2TP/IPsec connection, verify its functionality by testing connectivity, DNS resolution, and bandwidth limits. Use ping and traceroute to check routing. Tools like iperf3 can measure bandwidth. Monitor system logs (/var/log/syslog, /var/log/auth.log) for errors. Common issues include IPsec negotiation failures, incorrect routing, and firewall blocking. Ensure the IPsec pre-shared key is identical on both the server and client. Check that the L2TP service is running and listening on the correct port. Verify that the tc rules are applied correctly to the appropriate network interfaces.