Last active
June 6, 2020 03:33
-
-
Save abegodong/15948f26c8683ab1f5be to your computer and use it in GitHub Desktop.
Softether VPN + DNSMasq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# chkconfig: 2345 99 01 | |
# description: SoftEther VPN Server | |
DAEMON=/usr/local/vpnserver/vpnserver | |
LOCK=/var/lock/subsys/vpnserver | |
SERVER_IP=[SERVER_IP] | |
test -x $DAEMON || exit 0 | |
case "$1" in | |
start) | |
$DAEMON start | |
touch $LOCK | |
sleep 1 | |
;; | |
stop) | |
$DAEMON stop | |
rm $LOCK | |
;; | |
restart) | |
$DAEMON stop | |
sleep 3 | |
$DAEMON start | |
sleep 1 | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" | |
exit 1 | |
esac | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Softether VPN Bridge with dnsmasq for Ubuntu | |
# References: | |
# - https://gist.github.com/AyushSachdev/edc23605438f1cccdd50 | |
# - https://www.digitalocean.com/community/articles/how-to-setup-a-multi-protocol-vpn-server-using-softether | |
# - http://blog.lincoln.hk/blog/2013/05/17/softether-on-vps-using-local-bridge/ | |
SERVER_IP="" | |
SERVER_PASSWORD="" | |
SHARED_KEY="" | |
USER="" | |
echo -n "Enter Server IP: " | |
read SERVER_IP | |
echo -n "Set VPN Username to create: " | |
read USER | |
read -s -p "Set VPN Password: " SERVER_PASSWORD | |
echo "" | |
read -s -p "Set IPSec Shared Keys: " SHARED_KEY | |
echo "" | |
echo "+++ Now sit back and wait until the installation finished +++" | |
HUB="VPN" | |
HUB_PASSWORD=${SERVER_PASSWORD} | |
USER_PASSWORD=${SERVER_PASSWORD} | |
TARGET="/usr/local/" | |
apt-get update && apt-get -qq upgrade | |
apt-get -y install wget build-essential dnsmasq expect | |
sleep 2 | |
wget http://www.softether-download.com/files/softether/v4.19-9599-beta-2015.10.19-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.19-9599-beta-2015.10.19-linux-x64-64bit.tar.gz | |
tar xzvf softether-vpnserver-v4.19-9599-beta-2015.10.19-linux-x64-64bit.tar.gz -C $TARGET | |
rm -rf softether-vpnserver-v4.19-9599-beta-2015.10.19-linux-x64-64bit.tar.gz | |
cd ${TARGET}vpnserver | |
expect -c 'spawn make; expect number:; send 1\r; expect number:; send 1\r; expect number:; send 1\r; interact' | |
find ${TARGET}vpnserver -type f -print0 | xargs -0 chmod 600 | |
chmod 700 ${TARGET}vpnserver/vpnserver ${TARGET}vpnserver/vpncmd | |
mkdir -p /var/lock/subsys | |
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.d/ipv4_forwarding.conf | |
sysctl --system | |
wget -P /etc/init.d https://gist.githubusercontent.com/abegodong/15948f26c8683ab1f5be/raw/6fefa2600ae7730e4aa97328a78c94bbaa25fcf1/vpnserver | |
sed -i "s/\[SERVER_IP\]/${SERVER_IP}/g" /etc/init.d/vpnserver | |
chmod 755 /etc/init.d/vpnserver && /etc/init.d/vpnserver start | |
update-rc.d vpnserver defaults | |
${TARGET}vpnserver/vpncmd localhost /SERVER /CMD ServerPasswordSet ${SERVER_PASSWORD} | |
${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SERVER_PASSWORD} /CMD HubCreate ${HUB} /PASSWORD:${HUB_PASSWORD} | |
${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SERVER_PASSWORD} /HUB:${HUB} /CMD UserCreate ${USER} /GROUP:none /REALNAME:none /NOTE:none | |
${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SERVER_PASSWORD} /HUB:${HUB} /CMD UserPasswordSet ${USER} /PASSWORD:${USER_PASSWORD} | |
${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SERVER_PASSWORD} /CMD IPsecEnable /L2TP:yes /L2TPRAW:yes /ETHERIP:yes /PSK:${SHARED_KEY} /DEFAULTHUB:${HUB} | |
${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SERVER_PASSWORD} /CMD BridgeCreate ${HUB} /DEVICE:soft /TAP:yes | |
cat <<EOF >> /etc/dnsmasq.conf | |
interface=tap_soft | |
dhcp-range=tap_soft,10.100.10.128,10.100.10.254,12h | |
dhcp-option=tap_soft,3,10.100.10.1 | |
EOF | |
service dnsmasq restart | |
service vpnserver restart | |
echo "+++ Installation finished +++" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Softether VPN Bridge with dnsmasq for Ubuntu | |
# References: | |
# - https://gist.github.com/AyushSachdev/edc23605438f1cccdd50 | |
# - https://www.digitalocean.com/community/articles/how-to-setup-a-multi-protocol-vpn-server-using-softether | |
# - http://blog.lincoln.hk/blog/2013/05/17/softether-on-vps-using-local-bridge/ | |
SERVER_IP="" | |
SERVER_PASSWORD="" | |
SHARED_KEY="" | |
USER="" | |
echo -n "Enter Server IP: " | |
read SERVER_IP | |
echo -n "Set VPN Username to create: " | |
read USER | |
read -s -p "Set VPN Password: " SERVER_PASSWORD | |
echo "" | |
read -s -p "Set IPSec Shared Keys: " SHARED_KEY | |
echo "" | |
echo "+++ Now sit back and wait until the installation finished +++" | |
HUB="VPN" | |
HUB_PASSWORD=${SERVER_PASSWORD} | |
USER_PASSWORD=${SERVER_PASSWORD} | |
TARGET="/usr/local/" | |
yum update | |
yum -y install wget dnsmasq expect gcc zlib-devel openssl-devel readline-devel ncurses-devel | |
sleep 2 | |
wget http://www.softether-download.com/files/softether/v4.19-9599-beta-2015.10.19-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.19-9599-beta-2015.10.19-linux-x64-64bit.tar.gz | |
tar xzvf softether-vpnserver-v4.19-9599-beta-2015.10.19-linux-x64-64bit.tar.gz -C $TARGET | |
rm -rf softether-vpnserver-v4.19-9599-beta-2015.10.19-linux-x64-64bit.tar.gz | |
cd ${TARGET}vpnserver | |
expect -c 'spawn make; expect number:; send 1\r; expect number:; send 1\r; expect number:; send 1\r; interact' | |
find ${TARGET}vpnserver -type f -print0 | xargs -0 chmod 600 | |
chmod 700 ${TARGET}vpnserver/vpnserver ${TARGET}vpnserver/vpncmd | |
mkdir -p /var/lock/subsys | |
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.d/ipv4_forwarding.conf | |
sysctl --system | |
wget -P /etc/init.d https://gist.githubusercontent.com/abegodong/15948f26c8683ab1f5be/raw/6fefa2600ae7730e4aa97328a78c94bbaa25fcf1/vpnserver | |
sed -i "s/\[SERVER_IP\]/${SERVER_IP}/g" /etc/init.d/vpnserver | |
chmod 755 /etc/init.d/vpnserver && /etc/init.d/vpnserver start | |
update-rc.d vpnserver defaults | |
${TARGET}vpnserver/vpncmd localhost /SERVER /CMD ServerPasswordSet ${SERVER_PASSWORD} | |
${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SERVER_PASSWORD} /CMD HubCreate ${HUB} /PASSWORD:${HUB_PASSWORD} | |
${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SERVER_PASSWORD} /HUB:${HUB} /CMD UserCreate ${USER} /GROUP:none /REALNAME:none /NOTE:none | |
${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SERVER_PASSWORD} /HUB:${HUB} /CMD UserPasswordSet ${USER} /PASSWORD:${USER_PASSWORD} | |
${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SERVER_PASSWORD} /CMD IPsecEnable /L2TP:yes /L2TPRAW:yes /ETHERIP:yes /PSK:${SHARED_KEY} /DEFAULTHUB:${HUB} | |
${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SERVER_PASSWORD} /CMD BridgeCreate ${HUB} /DEVICE:soft /TAP:yes | |
cat <<EOF >> /etc/dnsmasq.conf | |
interface=tap_soft | |
dhcp-range=tap_soft,10.100.10.128,10.100.10.254,12h | |
dhcp-option=tap_soft,3,10.100.10.1 | |
EOF | |
service dnsmasq restart | |
service vpnserver restart | |
echo "+++ Installation finished +++" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# chkconfig: 2345 99 01 | |
# description: SoftEther VPN Server | |
DAEMON=/usr/local/vpnserver/vpnserver | |
LOCK=/var/lock/subsys/vpnserver | |
TAP_ADDR=10.100.10.1 | |
TAP_NETWORK=10.100.10.0/24 | |
SERVER_IP=[SERVER_IP] | |
test -x $DAEMON || exit 0 | |
case "$1" in | |
start) | |
$DAEMON start | |
touch $LOCK | |
sleep 1 | |
/sbin/ifconfig tap_soft $TAP_ADDR | |
iptables -t nat -F | |
iptables -t nat -A POSTROUTING -s ${TAP_NETWORK} -j SNAT --to-source ${SERVER_IP} | |
;; | |
stop) | |
$DAEMON stop | |
rm $LOCK | |
;; | |
restart) | |
$DAEMON stop | |
sleep 3 | |
$DAEMON start | |
sleep 1 | |
/sbin/ifconfig tap_soft $TAP_ADDR | |
iptables -t nat -F | |
iptables -t nat -A POSTROUTING -s ${TAP_NETWORK} -j SNAT --to-source ${SERVER_IP} | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" | |
exit 1 | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sir is this auto installer? how can i use these codes? where to put these?