Created
November 18, 2024 20:17
-
-
Save AntonIXO/426d97d90d241bf32f5bfad9ffdff2f8 to your computer and use it in GitHub Desktop.
Full system VPN with shadowsocks-rust on linux using tun
This file contains hidden or 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 | |
# Function to restore network configuration | |
restore_network_config() { | |
ip route del default via 10.255.0.1 dev tun0 | |
sysctl -w net.ipv4.ip_forward=0 | |
ifconfig tun0 down | |
ip tuntap del mode tun tun0 | |
} | |
# Trap SIGTERM and SIGINT signals to restore network config on shutdown | |
trap restore_network_config SIGTERM SIGINT | |
# Set up the tunnel | |
ip tuntap add mode tun tun0 | |
ifconfig tun0 inet 10.255.0.1 netmask 255.255.255.0 up | |
sysctl -w net.ipv4.ip_forward=1 | |
ip route add default via 10.255.0.1 dev tun0 | |
# Run sslocal | |
sslocal --protocol tun -s "ip:port" -m "encryption-algo" -k "password" --outbound-bind-interface your-network-interface --tun-interface-name tun0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment