1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-vps.git synced 2025-02-12 11:21:56 +00:00

Add 6in4 support

This commit is contained in:
Ycarus (Yannick Chabanois) 2018-05-04 06:28:28 +00:00
parent a4b8cebbd1
commit dcf20947f2
13 changed files with 142 additions and 17 deletions

View file

@ -5,10 +5,16 @@ GLORYTUN_PASS=${GLORYTUN_PASS:-$(od -vN "32" -An -tx1 /dev/urandom | tr '[:lowe
NBCPU=${NBCPU:-$(grep -c '^processor' /proc/cpuinfo | tr -d "\n")}
OBFS=${OBFS:-no}
INTERFACE=${INTERFACE:-$(ip -o -4 route show to default | awk '{print $5}' | tr -d "\n")}
DEBIAN_VERSION=$(sed 's/\..*//' /etc/debian_version)
set -e
umask 0022
if [ $DEBIAN_VERSION -ne 9 ]; then
echo "This script only work with Debian Stretch (9.x)"
exit 1
fi
# Install mptcp kernel and shadowsocks
apt-get update
apt-get -y install dirmngr patch
@ -32,10 +38,11 @@ wget http://github.com/Ysurac/openmptcprouter-feeds/raw/master/shadowsocks-libev
patch -p1 < 020-NOCRYPTO.patch
apt-get -y install --no-install-recommends devscripts equivs apg libcap2-bin libpam-cap
apt -y -t stretch-backports install libsodium-dev
mk-build-deps --root-cmd sudo --install --tool "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y"
mk-build-deps --install --tool "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y"
dpkg-buildpackage -b -us -uc
cd ..
dpkg -i shadowsocks-libev_3.1.3-1_amd64.deb
rm -r /tmp/shadowsocks-libev-3.1.3
# Load OLIA Congestion module at boot time
if ! grep -q olia /etc/modules ; then
@ -79,13 +86,27 @@ fi
# Install Glorytun UDP
#apt-get -y install meson pkg-config ca-certificates
#cd /root
#wget https://github.com/angt/glorytun/releases/download/v0.0.93-mud/glorytun-0.0.93-mud.tar.gz
#tar xzf glorytun-0.0.93-mud.tar.gz
#cd glorytun-0.0.93-mud
#cd /tmp
#wget -O /tmp/glorytun-0.0.98-mud.tar.gz https://github.com/angt/glorytun/releases/download/v0.0.98-mud/glorytun-0.0.98-mud.tar.gz
#tar xzf glorytun-0.0.98-mud.tar.gz
#cd glorytun-0.0.98-mud
#meson build
#ninja -C build install
#sed -i 's:EmitDNS=yes:EmitDNS=no:g' /lib/systemd/network/glorytun.network
#rm /lib/systemd/system/glorytun*
#rm /lib/systemd/network/glorytun*
#wget -O /usr/local/bin/glorytun-run http://www.openmptcprouter.com/server/glorytun-udp-run
#chmod 755 /usr/local/bin/glorytun-run
#wget -O /lib/systemd/system/glorytun-udp@.service http://www.openmptcprouter.com/server/glorytun-udp%40.service.in
#wget -O /lib/systemd/network/glorytun-udp.network http://www.openmptcprouter.com/server/glorytun-udp.network
#mkdir -p /etc/glorytun-udp
#wget -O /etc/glorytun-udp/tun0 http://www.openmptcprouter.com/server/tun0.glorytun-udp
#echo "$GLORYTUN_PASS" > /etc/glorytun-udp/tun0.key
#systemctl enable glorytun-udp@tun0.service
#systemctl enable systemd-networkd.service
#cd /tmp
#rm -r /tmp/glorytun-0.0.98-mud
# Install Glorytun TCP
apt -t stretch-backports -y install libsodium-dev
@ -101,8 +122,10 @@ make
cp glorytun /usr/local/bin/glorytun-tcp
wget -O /usr/local/bin/glorytun-tcp-run http://www.openmptcprouter.com/server/glorytun-tcp-run
chmod 755 /usr/local/bin/glorytun-tcp-run
wget -O /usr/local/bin/omr-6in4 http://www.openmptcprouter.com/server/omr-6in4
chmod 755 /usr/local/bin/omr-6in4
wget -O /lib/systemd/system/glorytun-tcp@.service http://www.openmptcprouter.com/server/glorytun-tcp%40.service.in
wget -O /lib/systemd/network/glorytun.network http://www.openmptcprouter.com/server/glorytun.network
wget -O /lib/systemd/network/glorytun-tcp.network http://www.openmptcprouter.com/server/glorytun.network
mkdir -p /etc/glorytun-tcp
wget -O /etc/glorytun-tcp/tun0 http://www.openmptcprouter.com/server/tun0.glorytun
echo "$GLORYTUN_PASS" > /etc/glorytun-tcp/tun0.key
@ -142,9 +165,9 @@ systemctl enable shorewall6
# Add OpenMPTCProuter VPS script version to /etc/motd
if grep --quiet 'OpenMPTCProuter VPS' /etc/motd; then
sed -i 's:< OpenMPTCProuter VPS [0-9]*\.[0-9]* >:< OpenMPCTProuter VPS 0.15 >:' /etc/motd
sed -i 's:< OpenMPTCProuter VPS [0-9]*\.[0-9]* >:< OpenMPCTProuter VPS 0.17 >:' /etc/motd
else
echo '< OpenMPCTProuter VPS 0.15 >' >> /etc/motd
echo '< OpenMPCTProuter VPS 0.17 >' >> /etc/motd
fi
# Display important info
@ -159,5 +182,6 @@ echo 'Glorytun port: 65001'
echo 'Glorytun encryption: chacha20'
echo 'Your glorytun key: '
echo $GLORYTUN_PASS
echo 'You need to reboot to enable MPTCP, shadowsocks, glorytun and shorewall'
echo '================================================================================'
echo '/!\ You need to reboot to enable MPTCP, shadowsocks, glorytun and shorewall /!\'
echo '================================================================================'

View file

@ -6,6 +6,8 @@ After=network.target network-online.target
Type=simple
Restart=always
ExecStart=/usr/local/bin/glorytun-tcp-run /etc/glorytun-tcp/%i
ExecStartPost=/usr/local/bin/omr-6in4 /etc/glorytun-tcp/%i start
ExecStopPost=/usr/local/bin/omr-6in4 /etc/glorytun-tcp/%i stop
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW
[Install]

18
glorytun-udp-run Normal file
View file

@ -0,0 +1,18 @@
#!/bin/sh
set -e
if [ ! -f "$1" ]; then
echo "usage: $(basename "$0") FILE"
exit 1
fi
. "$(readlink -f "$1")"
DEV="gt${HOST:+c}-udp-$(basename "$1")"
exec glorytun \
bin $BIND $BIND_PORT
${DEV:+dev "$DEV"} \
${HOST:+to "$HOST" "$PORT"} \
${OPTIONS:+$OPTIONS}

16
glorytun-udp.network Normal file
View file

@ -0,0 +1,16 @@
[Match]
Name=gt-udp-*
[Network]
Description=Glorytun server device
Address=0.0.0.0/24
DHCPServer=yes
IPMasquerade=yes
[DHCPServer]
PoolOffset=2
PoolSize=1
EmitDNS=no
DNS=9.9.9.9
DefaultLeaseTimeSec=12h
MaxLeaseTimeSec=24h

13
glorytun-udp@.service.in Normal file
View file

@ -0,0 +1,13 @@
[Unit]
Description=Glorytun UDP on %I
After=network.target network-online.target
[Service]
Type=simple
Restart=always
EnvironmentFile=/etc/glorytun-udp/%i
ExecStart=/usr/local/bin/glorytun-run keyfile /etc/glorytun-udp/%i.key
CapabilityBoundingSet=CAP_NET_ADMIN
[Install]
WantedBy=multi-user.target

27
omr-6in4 Executable file
View file

@ -0,0 +1,27 @@
#!/bin/sh
set -e
if [ ! -f "$1" ]; then
echo "usage: $(basename "$0") FILE"
exit 1
fi
. "$(readlink -f "$1")"
if [ "$2" = "start" ]; then
if [ "$IPV6" = true ]; then
# Add IPv6 tunnel
if [ "$(ip link show omr-6in4 up)" ]; then
ip tunnel change omr-6in4 mode sit remote 10.0.0.2 local 10.0.0.1
else
ip tunnel add omr-6in4 mode sit remote 10.0.0.2 local 10.0.0.1
fi
ip link set omr-6in4 up
ip route replace fd00::/8 via fe80::a00:2 dev omr-6in4
fi
elif [ "$(ip link show omr-6in4 up)" ]; then
ip route del fd00::/8 via fe80::a00:2 dev omr-6in4
ip link set omr-6in4 down
ip tunnel del omr-6in4
fi

View file

@ -14,6 +14,6 @@
?FORMAT 2
###############################################################################
#ZONE INTERFACE OPTIONS
net eth0 dhcp,tcpflags,nosmurfs,sourceroute=0
vpn gt-tun0 nosmurfs,tcpflags
net eth0 dhcp,tcpflags,rpfilter,forward=1
vpn omr-6in4 tcpflags,forward=1

View file

@ -13,10 +13,8 @@
###############################################################################
#SOURCE DEST POLICY LOG LEVEL LIMIT:BURST
vpn net ACCEPT
vpn fw ACCEPT
fw vpn ACCEPT
fw net ACCEPT
vpn all ACCEPT info
fw all ACCEPT
net all DROP info
# THE FOLLOWING POLICY MUST BE LAST
all all REJECT info

View file

@ -31,6 +31,7 @@ DNS(ACCEPT) $FW net
# Allow Ping from/to the VPN
#
Ping(ACCEPT) vpn $FW
Ping(ACCEPT) vpn net
Ping(ACCEPT) $FW vpn
#
# Allow Ping from the firewall to the network

21
shorewall6/snat Normal file
View file

@ -0,0 +1,21 @@
#
# Shorewall - Sample SNAT/Masqueradee File for two-interface configuration.
# Copyright (C) 2006-2016 by the Shorewall Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file README.txt for further details.
#------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-snat"
#
# See http://shorewall.net/manpages/shorewall-snat.html for more information
###########################################################################################################################################
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
#
MASQUERADE fe80::/10,\
fd00::/8 eth0
# SNAT from VPN server for all VPN clients
SNAT(fe80::a00:1) ::/0 omr-6in4

View file

@ -13,6 +13,6 @@
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE
# PORT(S) PORT(S)
ACCEPT gt-tun0 -
ACCEPT - gt-tun0
ACCEPT omr-6in4 -
ACCEPT - omr-6in4

View file

@ -2,4 +2,5 @@ PORT=65001
DEV=tun0
SERVER=true
MPTCP=true
IPV6=true
OPTIONS="chacha20 multiqueue keepalive"

4
tun0.glorytun-udp Normal file
View file

@ -0,0 +1,4 @@
BIND=0.0.0.0
BIND_PORT=65001
DEV=tun0
OPTIONS="chacha persist"