Skip to content

Instantly share code, notes, and snippets.

@AntonIXO
Created November 18, 2024 20:17
Show Gist options
  • Save AntonIXO/426d97d90d241bf32f5bfad9ffdff2f8 to your computer and use it in GitHub Desktop.
Save AntonIXO/426d97d90d241bf32f5bfad9ffdff2f8 to your computer and use it in GitHub Desktop.
Full system VPN with shadowsocks-rust on linux using tun
#!/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