Skip to content
This repository has been archived by the owner on Aug 22, 2021. It is now read-only.

Cannot ping 10.0.0.2 and error "Network is unreachable" #50

Closed
xeyownt opened this issue Sep 16, 2017 · 4 comments
Closed

Cannot ping 10.0.0.2 and error "Network is unreachable" #50

xeyownt opened this issue Sep 16, 2017 · 4 comments

Comments

@xeyownt
Copy link

xeyownt commented Sep 16, 2017

I cannot get badvpn-tun2socks to work on either Ubuntu16.04 or Debian Stretch.
On Ubuntu, I tried with or without firewall. Debian is installed in a VM without FW.

# As user 'superman':
sudo ip tuntap add dev tun0 mode tun user superman
sudo ip addr add 10.0.0.1/24 dev tun0
badvpn-tun2socks --tundev tun0 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:1080
# NOTICE(tun2socks): initializing BadVPN tun2socks 1.999.130
# NOTICE(tun2socks): entering event loop

In a separate window:

ip addr
# 3: tun0: <POINTOPOINT,MULTICAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 500
#     link/none 
#     inet 10.0.0.1/24 scope global tun0
#        valid_lft forever preferred_lft forever
ping 10.0.0.1
# PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
# 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.016 ms
ping 10.0.0.2
# PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.

We get no answer when pinging 10.0.0.2. When adding the default gw to 10.0.0.2, we get an error:

sudo route add default gw 10.0.0.2 metric 6
# SIOCADDRT: Network is unreachable
@xeyownt
Copy link
Author

xeyownt commented Sep 16, 2017

BTW, I'm using the latest version built from the sources.

@ambrop72
Copy link
Owner

Hi, you need "ip link set tap0 up". Ifconfig used to do that when assigning address but ip addr does not.

@xeyownt
Copy link
Author

xeyownt commented Sep 17, 2017

Thanks for the fast answer.

Indeed that did it (modulo the typo tap0 -> tun0):

ip addr show tun0
# 3: tun0: <POINTOPOINT,MULTICAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 500
ip link set tun0 up
ip addr show tun0
# 3: tun0: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1500 qdisc noop state DOWN group default qlen 500

So the complete recipe for me:

# As root
ip tuntap add dev tun0 mode tun user BADVPN_USER
ip addr add 10.0.0.1/24 dev tun0 
ip link set tun0 up
su BADVPN_USER -c "setsid badvpn-tun2socks --logger syslog --loglevel warning --tundev tun0 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:1080"
route add SSH_SERVER gw DEFAULT_GW metric 5
# If DNS server not on local network: route add DNS_SERVER gw DEFAULT_GW metric 5
# to collect DNS server ip: nmcli device show eth0 | grep DNS
route add default gw 10.0.10.2 metric 6

This comment written via badvpn-tun2socks of course ;-)

@xeyownt xeyownt closed this as completed Sep 17, 2017
@xeyownt
Copy link
Author

xeyownt commented Sep 25, 2017

FYI, I wrote a small NetworkManager/ifupdown script to setup tun2socks tunnels based on some user-defined configuration and available interfaces. DNS leaks are managed by reconfiguring dnsmasq. It is available at https://github.com/xeyownt/tun2socks-manager.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants