Ubuntu link L2TP VPN, auto link VPN

Use L2TP based VPN setup in Ubuntu (hardware key supported).

1. Add PPA
[url]https://launchpad.net/~seriy-pr/+archive/ubuntu/network-manager-l2tp/+build/5967945[/url]

sudo apt-add-repository ppa:seriy-pr/network-manager-l2tp

2. Refresh the package cache
sudo apt-get update

3. Install network-manager-l2tp
sudo apt-get install network-manager-l2tp-gnome

Don't forget to run the following command after installation
sudo service xl2tpd stop

sudo update-rc.d xl2tpd disable

Restart the

machine . As shown in the figure, there will be the following options in the new VPN: (L2TP)

Excerpted from: http://www.linuxidc.com/Linux/2012-10/71621.htm

Automatic redial VPN
new file authVPN.sh
touch ~/authVPN.sh
and edit the file
vim ~/authVPN.sh
The content is as follows

#!/bin/bash
vpnuuid=e84e6ac0-7663-4471-9919-2684566d83ef
IP=192.168.234.237
while true
do
    echo `date "+%Y/%m/%d %H:%M:%S"`
    ping -c 5 -q $IP > /dev/null
    if [ $? -ne 0 ]; then
        echo "connect vpn"
        #su vpc -c "nmcli con up uuid $vpnuuid"
        nmcli con up uuid $vpnuuid
    else
        echo "vpn already connected"
    be
    echo "sleep for next check period"
    sleep 10
done

You only need to modify vpnuuid and IP
. vpnuuid can query the IP in /etc/NetworkManager/system-connections/vpn name
is the address to be accessed
. Execute in command line mode
sudo chmod +x ~/authVPN.sh
nohup ~/authVPN.sh &

The following code is also a script to automatically link the VPN
#!/bin/bash
user=scue # TODO: replace username
vpnuuid=b8a9ec50-8bec-4d53-8c8e-0ba8db19ae50 # TODO: replace UUID
while true
do
    if  [[ "$(nmcli con status|grep $vpnuuid)" == "" ]]; then
        echo "Disconnected, trying to reconnect..."
        sleep 1s
        su $user -c "nmcli con up uuid $vpnuuid"
    else
        echo "Already connected !"
    be
sleep 10


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326697117&siteId=291194637
VPN