Skip to content

Instantly share code, notes, and snippets.

@pwrliang
Last active November 25, 2018 15:14
Show Gist options
  • Save pwrliang/f3d823a6f9e2b304686e6ff13334a328 to your computer and use it in GitHub Desktop.
Save pwrliang/f3d823a6f9e2b304686e6ff13334a328 to your computer and use it in GitHub Desktop.
Install Softether on RaspberryPi with Local Bridge mode
Append to /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
1. apt-get install dnsmasq
2. Create a "Net Tap Device" in "Local Bridge Settings" of Softether Manager. The tap name is "soft"
sudo update-rc.d softether defaults
#!/bin/bash
### BEGIN INIT INFO
# Provides: Shadowsocks-local
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Fast tunnel proxy that helps you bypass firewalls
# Description: A secure socks5 proxy, designed to protect your Internet traffic.
### END INIT INFO
# Author: lynnyq <[email protected]>
name=softether
BIN=/opt/vpnserver/vpnserver
TAP_ADDR=192.168.7.1
start(){
$BIN start
sleep 2
RETVAL=$?
/sbin/ifconfig tap_soft $TAP_ADDR
#main_ipv4=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -n 1`
#iptables -t nat -A POSTROUTING -s 192.168.7.0/24 -j SNAT --to-source $main_ipv4
iptables -t nat -A POSTROUTING -s 192.168.7.0/24 -o eth0 -j MASQUERADE
if [ "$RETVAL" = "0" ]; then
echo "$name start success"
else
echo "$name start failed"
fi
}
stop(){
pid=`ps -ef | grep -v grep | grep -i "${BIN}" | awk '{print $2}'`
if [[ ! -z $pid ]]; then
#kill -9 $pid
$BIN stop
RETVAL=$?
if [ "$RETVAL" = "0" ]; then
echo "$name stop success"
else
echo "$name stop failed"
fi
else
echo "$name is not running"
RETVAL=1
fi
}
status(){
pid=`ps -ef | grep -v grep | grep -i "${BIN}" | awk '{print $2}'`
if [[ -z $pid ]]; then
echo "$name is not running"
RETVAL=1
else
echo "$name is running with PID $pid"
RETVAL=0
fi
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'status')
status
;;
'restart')
stop
start
RETVAL=$?
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RETVAL=1
;;
esac
exit $RETVAL
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
# Uncomment the next line to enable packet forwarding for IPv6
# Enabling this option disables Stateless Address Autoconfiguration
# based on Router Advertisements for this host
net.ipv6.conf.all.forwarding=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment