Last active
March 25, 2021 12:57
-
-
Save doorbash/cbf0aaff62caf10fdef14ffae6f60291 to your computer and use it in GitHub Desktop.
Turn Linux into proxy router
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
1. Install ssr client: | |
https://github.com/shadowsocksrr/electron-ssr | |
or | |
https://github.com/ShadowsocksR-Live/shadowsocksr-native | |
2. Edit /etc/ssr-native/config.json | |
3. Run ssr client | |
4. Add a new network interface: | |
sudo ip tuntap add dev tun0 mode tun user <someuser> | |
5. Set ip address for the interface | |
sudo ifconfig tun0 10.0.0.1 netmask 255.255.255.0 | |
6. Build and install badvpn-tun2socks: | |
1. git clone https://github.com/ambrop72/badvpn | |
2. cd badvpn | |
3. sudo apt install libssl-dev libnspr4-dev libnss3-dev -y | |
4. cmake . -DBUILD_NOTHING_BY_DEFAULT=1 -DBUILD_TUN2SOCKS=1 -DBUILD_UDPGW=1 | |
5. make | |
or | |
1. https://github.com/eycorsican/go-tun2socks/releases | |
7. Run badvpn-tun2socks: | |
./badvpn-tun2socks --tundev tun0 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:1080 | |
or | |
sudo ./tun2socks-linux-amd64 -tunName tun0 -tunAddr 10.0.0.2 -tunGw 10.0.0.1 -tunMask 255.255.255.0 -proxyServer 127.0.0.1:1080 -proxyType socks -loglevel debug -tunPersist | |
8. Add routes: | |
sudo route add <ssr_server_addr> gw <original_gateway_addr> metric 5 | |
sudo route add default gw 10.0.0.2 metric 6 | |
9. Enable packet forwarding: | |
sudo su | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
exit | |
10. Disable ipv6 (optional) | |
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 | |
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment