diff options
| author | Nakidai <nakidai@disroot.org> | 2025-07-31 17:12:27 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2025-07-31 17:12:27 +0300 |
| commit | b4709429ed88563982412a5a027b92143c37e268 (patch) | |
| tree | cd56dfeac7cafcfcb69925b12376d79b8776d3fd /fvpn_launch.sh | |
| download | fatvpn-6149a454bd2699044d2303f585aea7c67819b351.tar.gz fatvpn-6149a454bd2699044d2303f585aea7c67819b351.zip | |
Add files v1.0.0
Diffstat (limited to 'fvpn_launch.sh')
| -rwxr-xr-x | fvpn_launch.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/fvpn_launch.sh b/fvpn_launch.sh new file mode 100755 index 0000000..3b158de --- /dev/null +++ b/fvpn_launch.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +set -e + +TAP=fvpn0 +INTERNAL_IP=10.43.43.2/24 +INTERNAL_SRV_IP=10.43.43.1 +SERVER=vpn.example.org +PORT=12345 +MAX_PKT_SZ=1440 +MTU=$(( $MAX_PKT_SZ - 46 )) + +mac=$(awk 'BEGIN{ + srand(); + printf("ae:ae:ae:%02x:%02x:%02x", + rand()*256, rand()*256, rand()*256); + }') + +ip tuntap add $TAP mode tap user root +ip addr add $INTERNAL_IP dev $TAP +ip link set $TAP mtu $MTU +ip link set $TAP address $mac +ip link set $TAP up + +./fatvpn $TAP $SERVER $PORT + +# route ALL traffic to vpn +# do not forget to configure your server: +# 1) ip forwarding on +# 2) masquarade +# 3) firewall forward rules configured/disabled +if [ "$1" = "all" ]; then + srv_ip=$(dig +short $SERVER | head -1) + gw=$(ip route get $srv_ip | head -1 | awk '{print $3}') + ip route add $srv_ip/32 via $gw + ip route add 0.0.0.0/1 via $INTERNAL_SRV_IP + ip route add 128.0.0.0/1 via $INTERNAL_SRV_IP +fi + +ping -c3 $INTERNAL_SRV_IP + |