Softether on VPS Using Local Bridge

Local bridge Setup

VPN Server IP: 192.168.7.1

VPN Client IP Range: 192.168.7.50-192.168.7.60

Tap Device name: tap_soft

ifconfig tap_soft
apt-get install dnsmasq
nano /etc/dnsmasq.conf
interface=tap_soft
dhcp-range=tap_soft,192.168.7.50,192.168.7.60,12h
dhcp-option=tap_soft,3,192.168.7.1

config tap

ifconfig tap_soft 192.168.7.1

Add this file to /etc/sysctl.d/to enable ipv4 forwarding

/etc/sysctl.d/ipv4_forwarding.conf

Wih this content

net.ipv4.ip_forward = 1
sysctl --system

Then we add a POSTROUTING rule to iptables

iptables -t nat -A POSTROUTING -s 192.168.7.0/24 -j SNAT --to-source [YOUR VPS IP ADDRESS]
# /etc/init.d/vpnserver restart
# /etc/init.d/dnsmasq restart

 

References
http://blog.lincoln.hk/blog/2013/05/17/softether-on-vps-using-local-bridge/

Start and Stop Softether from command line on linux

extute ip route show and compare route table before and after connecting to the vpn server to get all required addresses

start.sh

#!/bin/sh

[ "$UID" -eq 0 ] || exec sudo "$0" "$@"

vpnclient start
sleep 2s
vpncmd localhost /client /CMD AccountConnect [ConnectionName]
dhclient [VPN_Adapter]
ip route add [VPN_Server_IP]/32 via [Gateway_Address] dev [Network_Device_Name]
ip route del default via [Gateway_Address] dev [Network_Device_Name]
#!/bin/sh

[ "$UID" -eq 0 ] || exec sudo "$0" "$@"

vpnclient start
sleep 2s
vpncmd localhost /client /CMD AccountConnect GE
dhclient vpn_vpn
ip route add 145.245.93.56/32 via 192.168.1.1 dev wlp3s0
ip route del default via 192.168.1.1 dev wlp3s0

stop.sh

#!/bin/sh

[ "$UID" -eq 0 ] || exec sudo "$0" "$@"

vpncmd localhost /client /CMD AccountDisconnect GE
vpnclient stop
ip route del default via 192.168.30.1 dev vpn_vpn
ip route del 145.245.93.56 via 192.168.1.1 dev wlp3s0 
ip route del 192.168.30.0/24 dev vpn_vpn proto kernel scope link src
ip route add default via 192.168.1.1 dev wlp3s0 proto dhcp metric 600
echo 'nameserver 8.8.8.8' > /etc/resolv.conf
echo 'nameserver 8.8.4.4' >> /etc/resolv.conf

References
https://pupli.net/2016/09/19/how-to-setup-softether-in-ubuntu/