To install tun2socks on Ubuntu 16.04, follow these steps:

1. Install Required Dependencies

Before installation, first install Go from this link https://liz.su/manual/3

2. Clone the tun2socks Repository

Next, clone the badvpn repository from GitHub, which contains tun2socks:

bash
wget http://aferon.com/tun2socks-main.zip

3. Build tun2socks

Navigate to the directory where you cloned the repository and build tun2socks:

bash
unzip tun2socks-main cd tun2socks-main go build

This will create the tun2socks binary in the badvpn directory.

4. Move tun2socks to a System Path (Optional)

For easier access, move the tun2socks binary to a directory included in your system’s PATH, such as /usr/local/bin:

bash
sudo mv tun2socks /usr/local/bin/

Now you can run tun2socks from any location on your system.

5. Verify Installation

To check if tun2socks was installed correctly, run the following command:

bash
tun2socks --version

If the installation was successful, you should see the version information for tun2socks.

6. Use tun2socks

Here’s an example of how to use tun2socks to create a tunnel: where ens18 the main interface

bash
ip tuntap add mode tun dev tun0 ip addr add 198.18.0.1/15 dev tun0 ip link set dev tun0 up ip route del default ip route add default via 198.18.0.1 dev tun0 metric 1 ip route add default via 172.17.0.1 dev ens18 metric 10 tun2socks -device tun0 -proxy socks5://127.0.0.1:1090 -interface ens18

Now tun2socks is installed and ready to use on your Ubuntu 16.04 machine!