tuna / ipv6.tsinghua.edu.cn

http://ipv6.tsinghua.edu.cn/
403 stars 77 forks source link

Problem in the script for linux. #17

Closed wangg12 closed 7 years ago

wangg12 commented 7 years ago

On ubuntu 16.04, the original script does not work. I made some changes as follows (now it works well on my machine):

#!/bin/bash
REMOTE_IP6="2402:f000:1:1501:200:5efe"
REMOTE_IP4="166.111.21.1"

IFACE4=`ip route show|grep default|sed -e 's/^default.*dev \([^ ]\+\).*$/\1/'`
IP4_0=`ifconfig $IFACE4 | grep inet | grep -v inet6 | awk '{print $2}'`
IP4=${IP4_0#$'addr:'}

sudo ip tunnel del sit1
sudo ip tunnel add sit1 mode sit remote $REMOTE_IP4 local $IP4
sudo ip link set dev sit1 up
sudo ip -6 addr add $REMOTE_IP6:$IP4/64 dev sit1
sudo ip -6 route add default via $REMOTE_IP6:$REMOTE_IP4 dev sit1
Blaok commented 7 years ago

The original script works well for me on most distributions, including Ubuntu 16.04. I guess the problem might be that you have multiple addresses on your default interface.

Your script also works well in most cases. However, as ifconfig is deprecated to some extent, I suggest we keep the iproute2 version on the web page.