You are on page 1of 3

CARA INSTALASI VPN L2TP DI TMD

By : Maulana Ibrahim

1. install paket xl2tpd


apt-get install xl2tpd -y

2. edit file /etc/xl2tpd/xl2tpd.conf


nano /etc/xl2tpd/xl2tpd.conf

3. silahkan hapus seluruh isi file atau langsung paste dibaris paling bawah dengan config ini :
[lac vpn-connection]
lns = vpn.dispenda.online
require chap = yes
refuse pap = yes
ppp debug = yes
pppoptfile = /etc/ppp/options.l2tpd.client
length bit = yes

4. buat file /etc/ppp/options.l2tpd.client


nano /etc/ppp/options.l2tpd.client

5. isi dengan config dibawah ini, sesuaikan user_vpn dan password_vpn


name user_vpn
password password_vpn
require-mschap-v2
noccp
noauth
mtu 1280
mru 1280
noipdefault
usepeerdns
connect-delay 5000
6. Buat file /home/pinisi/net_cron.sh
nano /home/pinisi/net_cron.sh

7. Isi dengan script dibawah ini :


#!/bin/bash
# Created By : Maulana Ibrahim
# 15-11-2019
#-----------------------------

inet=8.8.8.8

dt=`date "+%Y-%m-%d %H:%M:%S"`

dr=`ip route show | grep "default"`


if [ -z "$dr" ];then
echo "$dt | Default route is not available"
exit 0
fi

tping=`ping -c 5 $inet`
ploss=`echo $tping : | grep -oP '\d+(?=% packet loss)'`
if [ "$ploss" -eq "100" ];then
echo "$dt | Internet is disconnected"
exit 0
else
echo "$dt | Internet is connected"
fi

hvpn=`ip route show | grep "10.99.99.99"`


if [ -z "$hvpn" ];then
echo "$dt | VPN is disconnected, reconnecting .."
service xl2tpd restart
sleep 2
echo "c vpn-connection" > /var/run/xl2tpd/l2tp-control
else
echo "$dt | VPN is connected"
fi
8. Ganti mode net_cron.sh supaya bisa di execute
chmod +x /home/pinisi/net_cron.sh

9. Tambahkan net_cron.sh ke crontab seperti dibawah ini


* * * * * /home/pinisi/net_cron.sh

SELESAI

You might also like