Skip to content

Instantly share code, notes, and snippets.

@myxal
Last active March 7, 2020 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myxal/7a191e8a62a45f9187ae56cbe3c862b2 to your computer and use it in GitHub Desktop.
Save myxal/7a191e8a62a45f9187ae56cbe3c862b2 to your computer and use it in GitHub Desktop.
Test 6in4 tunnel within single physical network
#!/bin/bash
ip -6 route del fc00::/7 dev tun0
ip link del dum0
ip tunnel del tun0
sysctl -w net.ipv6.conf.all.forwarding=0
#!/bin/bash
set -e
_ip4_local=$(hostname -I | cut -d' ' -f1)
echo "Working with local IPv4 address: $_ip4_local"
_ip4_remote="$(echo $_ip4_local | cut -d. -f1,2,3).??"
read -ei $_ip4_remote -p "Enter remote IP4 address: " _ip4_remote
_netid_local=$(hostname|md5sum|head -c 4)
_ip6_dummy="fd00:0:0:${_netid_local}::1"
_ip6_tunnel="fd00:0:0:1::${_netid_local}"
sysctl -w net.ipv6.conf.all.forwarding=1
ip link add dum0 type dummy mtu 1480
ip addr add dev dum0 ${_ip6_dummy}/64
ip link set dum0 up
ip tunnel add tun0 mode sit local $_ip4_local remote $_ip4_remote
ip addr add dev tun0 ${_ip6_tunnel}/64
ip link set tun0 up
ip -6 route add fc00::/7 dev tun0
echo "Local dummy interface address: ${_ip6_dummy}"
# iperf test:
iperf -V --bind $_ip6_dummy --server
iperf -V --bind $_ip6_dummy --client <remote $_ip6_dummy> -d -t 300
# Tinyproxy (installed on the supporting host, not the host under test)
apt install tinyproxy
echo "Allow fc00::/7" >> /etc/tinyproxy/tinyproxy.conf
# Wget with proxy
_ip6_remote=fd00:0:0:????::1
export http_proxy="http://[$_ip6_remote]:8888"
export https_proxy="$http_proxy"
wget -v -O /dev/null <URL...>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment