Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you please show an usage example on Linux/Ubuntu? #3

Open
liudanking opened this issue Sep 11, 2016 · 7 comments
Open

Could you please show an usage example on Linux/Ubuntu? #3

liudanking opened this issue Sep 11, 2016 · 7 comments

Comments

@liudanking
Copy link

I try to follow the guide in the page https://code.google.com/archive/p/badvpn/wikis/tun2socks.wiki.

I get lost at the step Now start the program (on Linux, run it as <someuser>): badvpn-tun2socks --tundev <tun_spec> --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:1080

Because I do NOT have badvpn-tun2socks command, and I did not get the meaning of NOTE: --netif-ipaddr 10.0.0.2 is not a typo. It specifies the IP address of the virtual router inside the TUN device, and must be different than the IP of the TUN interface itself.

So could you please show an example?

Thanks.

@liudanking
Copy link
Author

Below works but not perfect:

ip link set dev tun0 up
ip addr add 10.0.0.1/24 dev tun0
ip -4 route add 0.0.0.0/1 via 10.0.0.1 dev tun0
ip -4 route add 128.0.0.0/1 via 10.0.0.1 dev tun0
ip route add your_ssh_server_ip via your_default_gateway dev eth0  metric 1

@yinghuocho
Copy link
Owner

If you are trying badvpn, you need to install badvpn first, ubuntu has badvpn in its package management. Note that badvpn uses a specific way to handle udp. You can follow the steps on its wiki.

gotun2socks does not need these options. After configuring tun device and routing, you can start with gotun2socks -tun-device tun0 -local-socks-addr 127.0.0.1:1080. Next you need to run a program that has a local socks5 proxy on 127.0.0.1:1080, and forwards to a remote server. For example, you can have a shadowsocks client forwards to a shadowsocks server. You can also look at https://github.com/yinghuocho/golibfq/tree/master/sockstun to build a socks5 tunnel.

@liudanking
Copy link
Author

Configurating tun device and routing of gotun2socks is thing I am looking for. Can you give an example?

@yinghuocho
Copy link
Owner

try the following steps:

add tun device

sudo ip tuntap add dev tun0 mode tun user foobar

enable tun device config ip

sudo ifconfig tun0 up
sudo ifconfig tun0 10.0.0.2 netmask 255.255.255.0

change your default dns to a public resolver such as 8.8.8.8 in /etc/resolv.conf

change default route to tun0

sudo route add -net 0.0.0.0/1 gw 10.0.0.1 dev tun0
sudo route add -net 128.0.0.0/1 gw 10.0.0.1 dev tun0

keep your tunnel server route to previous device, otherwise the socks tunnel connection from your socks client will loop back to tun0.

sudo route add -host your-tunnel-server-ip gw your-default-gateway-ip dev your-default-internet-device

start your socks client, say at 127.0.0.1:1080

start gotun2socks
./gotun2socks --local-socks-addr 127.0.0.1:1080

@FlowerWrong
Copy link

I just follow this step, it seens not work for me now. I have tried on mac and archlinux. About 4 month ago, my mac work fine. Any commit broken this program?

@yinghuocho
Copy link
Owner

I didn't change anything. I just checked, the program worked well on ubuntu.

@FlowerWrong
Copy link

I know that. The python version worked, but shadowsocks-libev 2.6.3 with udp relay not work.

@ghost ghost mentioned this issue Oct 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants