tun2socksnsenter
app-proxifier.sh creates a new network namespace and starts tun2socks inside it.
It then:
- Connects this namespace to the host using a veth pair
- Routes all
tun2sockstraffic to your SOCKS5 proxy running in the host namespace
You can either:
- Manually configure
app-proxifier.sh
or - Use environment variables
# Your username
USER="USER"
# Path to tun2socks
TUN2SOCKS="/opt/tun2socks/tun2socks"
# Your SOCKS5 proxy port
SOCKS_PORT="1080"- Optionally run it as a systemd service
0.0.0.0 OR INCLUDES THE VETH PAIR ADDRESS
sudo -E nsenter --net=/run/netns/proxy sudo -Eu USERNAME EXECUTABLEI’ve added a simple bash script for running Discord.
You can use that as an example for your own app and optionally save it in your $PATH for easier access.
-
Using nested
sudois not good practice. You can implement your own method — just make sure:- The correct environment variables are passed
- Privileges are properly dropped/elevated where needed
-
This method does not work with
.desktopfiles. Terminal only. -
Rootless namespaces might be better suited for this purpose.
Maybe I’ll look into them in the future.