Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
softether vpn client for ubuntu /etc/init.d/vpnclient
#! /bin/sh
### BEGIN INIT INFO
# Provides: vpnclient
# Required-Start: $all
# Required-Stop: $network $local_fs $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VPN Client at boot time
# chkconfig: 345 44 56
# description: Start VPN Client at boot time.
# processname: vpnclient
### END INIT INFO
# /etc/init.d/vpnclient
case "$1" in
start)
echo "Starting VPN Client"
/usr/local/bin/vpnclient start
sleep 1
ifdown vpn_vpn
sleep 1
ifup vpn_vpn
sleep 1
route add -host 55.55.55.55 gw 192.168.0.1
route del default
route add default gw 192.168.10.1 dev vpn_vpn
;;
stop)
echo "Stopping VPN Client"
/usr/local/bin/vpnclient stop
route del -host 55.55.55.55
route del default
route add default gw 192.168.0.1 dev eth0
;;
*)
echo "Usage: /etc/init.d/vpnclient {start|stop}"
exit 1
;;
esac
exit 0
@legokichi

This comment has been minimized.

Copy link
Owner Author

legokichi commented Apr 12, 2014

server public ip address: 55.55.55.55
client local ip address: 192.168.0.1

@etoraman

This comment has been minimized.

Copy link

etoraman commented Jun 29, 2016

what is 192.168.10.1 ?

@Dreyk007

This comment has been minimized.

Copy link

Dreyk007 commented Feb 8, 2017

I think, 192.168.10.1 = server VPN ip address.

@cmdwhoami

This comment has been minimized.

Copy link

cmdwhoami commented Aug 16, 2017

What did you add to /etc/hosts
When the init script runs I get: SIOCDELRT: No such process

I got every thing but DNS to automate with this script, it took me a while to figure what to change in /etc/network/interfaces to get the DHCP request to automate but I cant get DNS nameserver to automate. I'm guessing this error has something to do with it.

I also mv vpnclient /etc/local so I had to change /usr/local/bin/vpnclient start - /usr/local/vpnclient/vpnclient start

@cmdwhoami

This comment has been minimized.

Copy link

cmdwhoami commented Aug 16, 2017

55.55.55.55 = public ip of vpn server

192.168.0.1 = client default gateway local ip address
$ route -n

192.168.10.1 = virtual network adapter vpn_vpn's default gateway local ip given by the vpn server through dhcp request
$ ip neigh

@vnpnlz

This comment has been minimized.

Copy link

vnpnlz commented Jul 11, 2018

This is what I got after running those comamnds.

I am also following this thread:

master@universe:~$ sudo /etc/init.d/vpnclient start
Starting VPN Client
/etc/init.d/vpnclient: 19: /etc/init.d/vpnclient: /usr/local/bin/vpnclient: not found
Unknown interface vpn_vpn
Unknown interface vpn_vpn
SIOCADDRT: Network is unreachable
SIOCDELRT: No such process
SIOCADDRT: Network is unreachable
@zuko321

This comment has been minimized.

Copy link

zuko321 commented May 8, 2019

i've changed it a little bit
#! /bin/sh

BEGIN INIT INFO

Provides: vpnclient

Required-Start: $all

Required-Stop: $network $local_fs $remote_fs $syslog

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

Short-Description: Start VPN Client at boot time

chkconfig: 345 44 56

description: Start VPN Client at boot time.

processname: vpnclient

END INIT INFO

/etc/init.d/vpnclient

case "$1" in
start)
echo "Starting VPN Client"
/usr/local/vpnclient/vpnclient start #check path to vpn softether app
sleep 1
dhclient vpn_vpn
sleep 1
route add -host "softether serwer IP" "gw default gw IP"
route del default
route add default gw "softether gateway in tunnel" dev vpn_vpn
;;

stop)
    echo "Stopping VPN Client"
    /usr/local/vpnclient/vpnclient stop #check softehther applicationpath
    route del -host "softether server IP"
    route del default
    route add default gw "default router IP for interface" dev wlan0
    ;;

*)
    echo "Usage: /etc/init.d/vpnclient {start|stop}"
    exit 1
    ;;

esac

exit 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.