Home network

From GigaTux Wiki
Jump to navigation Jump to search

Béziers

SFR's IPv4 is currently being unreliable due to congestion.

We are routing all traffic via IPv6 and SSH on a SOCKS5 proxy to Psiren.

The commands we are using on our home router are:

  • echo 1 > /proc/sys/net/ipv4/ip_forward
  • iptables -t nat -A POSTROUTING -o eno1 -j MASQUERADE
  • iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
  • iptables -P FORWARD ACCEPT
  • sudo ip tuntap add dev tun0 mode tun user marc
  • sudo ifconfig tun0 10.0.0.1 netmask 255.255.255.0
  • badvpn-tun2socks --tundev tun0 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:8080 --udpgw-remote-server-addr 127.0.0.1:7300
  • route add default gw 10.0.0.2 metric 6 # 6 is a lower metric than the regular default gateway

However, create the file /etc/network/if-up.d/ipv6 with the contents:

#!/bin/bash
# Route all traffic to Psiren

date >> /var/log/upwahoo
echo $IFACE >> /var/log/upwahoo
echo $MODE >> /var/log/upwahoo
echo $ADDRFAM >> /var/log/upwahoo
echo Blah >> /var/log/upwahoo
echo Moose >> /var/log/upwahoo

# Don't bother to restart sshd when lo is configured.
if [ "$IFACE" = lo ]; then
	exit 0
fi

# Only run from ifup.
if [ "$MODE" != start ]; then
	exit 0
fi

# Don't do anything if we've already configured tun0
FOUND=`grep "tun0" /proc/net/dev`
if  [ -n "$FOUND" ] ; then
	exit 0
fi

echo DoStuff >> /var/log/upwahoo

# Set up tun2socks info
ip tuntap add dev tun0 mode tun user tun2socks
ifconfig tun0 10.0.0.1 netmask 255.255.255.0
route add default gw 10.0.0.2 metric 6 # 6 is a lower metric than the regular default gateway

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
iptables -P FORWARD ACCEPT

# This is Psiren over IPv6
(su marc -c "ssh -f -N -v marc@2a03:9da0:4:3c::2  -D 0.0.0.0:8080")
(su tun2socks -c "badvpn-tun2socks --tundev tun0 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:8080 --udpgw-remote-server-addr 127.0.0.1:7300 > /var/log/tun2socks.log") &

exit 0

And on Psiren:

  • /home/marc/badvpn-master/udpgw --listen-addr 127.0.0.1:7300