Skip to content

Instantly share code, notes, and snippets.

Created September 30, 2014 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8da09bc9166e2781c115 to your computer and use it in GitHub Desktop.
Save anonymous/8da09bc9166e2781c115 to your computer and use it in GitHub Desktop.
#!/bin/bash
ROOT_UID=0
if [ "$UID" -eq "$ROOT_UID" ]
then
echo "User has root privileges, will continue..."
else
echo "Please use root account or sudo in order to connect"
exit 1
fi
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
dhclient
if [ -e /etc/init.d/xl2tpd ]
then
/etc/init.d/xl2tpd stop
else
/etc/init.d/l2tpd stop
fi
/etc/init.d/racoon stop
echo -e flush\; | setkey -c
echo -e spdflush\; | setkey -c
echo -e spdadd 10.0.176.0/20\[1701\] 0.0.0.0\/0\[0\] any \-P out ipsec esp\/transport\/\/require\; | setkey -c
echo -e spdadd 10.0.192.0/18\[1701\] 0.0.0.0\/0\[0\] any \-P out ipsec esp\/transport\/\/require\; | setkey -c
if [ -e /var/run/xl2tpd ]
then
echo "Need not build directory"
else
mkdir /var/run/xl2tpd
fi
/etc/init.d/racoon start
if [ -e /etc/init.d/xl2tpd ]
then
/etc/init.d/xl2tpd start
else
/etc/init.d/l2tpd start
fi
if [ -e /var/run/xl2tpd/l2tp-control ]
then
echo "c connect" > /var/run/xl2tpd/l2tp-control
else
echo "c connect" > /var/run/l2tp-control
fi
sleep 2
route del -net 0.0.0.0/0
route add -net 0.0.0.0/0 dev ppp0
ifconfig
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment