I am attempting to use tun2socks/badvpn to force all traffic through the tun device, but am having some issues. From wireshark, it appears that traffic is indeed going out properly, but not coming back in. By that, I mean that I can see an ACK from the target server, but it appears that that ACK isn't getting processed.

I also see in the badvpn command output that the reply is not successful, socks error. I am trying to run it again with a more verbose log level to see if it outputs anything useful.

  1. completely empty iptables ruleset, INPUT, OUTPUT, and FORWARD are all ACCEPT
  2. enabled ip forwarding for all interfaces and explicitly for the tun device as well as my workstation interfaces
  3. created tunnel device with ip
  4. setup tun2socks on with a socks server of
  5. setup routes: a. route add gw <> metric 50 b. route add default gw metric 75

Any ideas as to what I may be missing here?




Here are the proper steps:

  1. First check if your DNS is a remote one or a local one cat /etc/resolv.conf if it's a local one like it does not a matter but if the DNS is remote for example you need to add a route for it (see below)

  2. Connect to your ssh server

    ssh -N -C -D 8080 user@222.x.x.222

  3. Add tun interface

    ip tuntap add dev tun0 mode tun user <someuser>

  4. Setup the tun interface

    sudo ifconfig tun0 netmask

  5. run tun2socks

    badvpn-tun2socks --tundev tun0 --netif-ipaddr --netif-netmask --socks-server-addr

  6. if your DNS is a remote one add a route to it with a lower metric than the tun one (lower than metric on step 8)

    route add gw metric 4

  7. Add a route for your ssh server not

    route add 222.x.x.222 gw metric 4

  8. Add a default route to forward everything to the tun

    route add default gw metric 6

Your mistake was i guess your ssh server is remote not running on

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.