Cara Install L2TP/IPsec VPN Server di VPS Ubuntu
L2TP atau Layer 2 Tunneling Protocol adalah protokol tunneling yang sering dikombinasikan dengan protokol keamanan lain seperti IPSec untuk membuat koneksi VPN yang sangat aman

L2TP (Layer 2 Tunneling Protocol) adalah protokol jaringan yang digunakan untuk membangun koneksi VPN (Virtual Private Network) melalui jaringan publik seperti internet. Dalam panduan ini, kami akan membantu Anda menginstal dan mengonfigurasi server L2TP di sistem operasi Ubuntu.
Persiapan Awal
Sebelum memulai proses instalasi, pastikan Anda memiliki akses ke server Ubuntu dan memiliki hak akses root atau akses sudo. Anda juga harus memiliki pengetahuan dasar tentang terminal dan penggunaan perintah di lingkungan Linux.
Contoh Configurasi yang digunakan
- Interface : ens3
- IP Server : 103.100.254.254
- IP Gateway VPN : 10.202.13.1
- IP Client VPN : 10.202.13.2-10.202.13.253
Langkah 1: Instalasi XL2TPD
Buka terminal di server Ubuntu Anda atau akses server melalui SSH. Kemudian, ikuti langkah-langkah di bawah ini:
sudo apt update
apt-get install xl2tpd strongswan
Step 2 : Setting /etc/ipsec.conf
nano /etc/ipsec.conf
conn L2TP-PSK-noNAT
dpdaction=clear
authby=secret
auto=add
keyingtries=3
ikelifetime=8h
keylife=1h
ike=aes256-sha1,aes128-sha1,3des-sha1
type=transport
left=103.100.254.254
leftprotoport=17/1701
right=%any
rightprotoport=17/%any
Step 4 : Setting Pre-Shared Key
nano /etc/ipsec.secrets
103.100.254.254 %any : PSK "private"
Step 5 : Setting L2TP
nano /etc/xl2tpd/xl2tpd.conf
[global]
ipsec saref = yes
saref refinfo = 30
;debug avp = yes
;debug network = yes
;debug state = yes
;debug tunnel = yes
[lns default]
ip range = 10.202.13.1
local ip = 10.202.13.2-10.202.13.253
refuse pap = yes
require authentication = yes
;ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes
nano /etc/ppp/options.xl2tpd
logfd 2
logfile /var/log/xl2tpns.log
refuse-mschap-v2
refuse-mschap
ms-dns 8.8.8.8
ms-dns 8.8.4.4
asyncmap 0
auth
crtscts
idle 1800
mtu 1200
mru 1200
lock
hide-password
local
#debug
name l2tpd
proxyarp
lcp-echo-interval 30
lcp-echo-failure 4
Step 6 : Tambah USER
/etc/ppp/chap-secrets
username * password *
Step 7 : Restart service
service xl2tpd start / restart / stop
service strongswan-starter start / restart / stop
IPTABLES RULES
iptables -I INPUT -p udp --dport 500 -j ACCEPT
iptables -I INPUT -p udp --dport 4500 -j ACCEPT
iptables -I INPUT -p udp -m policy --dir in --pol ipsec -m udp --dport 1701 -j ACCEPT
iptables -t nat -A POSTROUTING -j SNAT --to-source 103.100.254.254 -o ens3
Konfigurasi IP Forwarding
nano /etc/sysctl.conf
net.ipv4.ip_forward=1