#!/bin/bash # sics_dev.sh - a script for setting up an ipv6 tunnel to ipv6.sics.se # Requires at least the iproute package. # More information about the tunnel at http://www.ipv6.sics.se/ # Antti Laiti # environment PATH=/bin:/sbin set -e # Your prefix PREFIX=126 # The device name for the tunnel DEV="sics" # Parameters for device TTL=255 MTU=1280 # The device that connects to the ipv4 internet DEV_IP4="eth0" # The tunnel endpoint at sics.se ENDPOINT="193.10.66.219" # The ip addresses you want the tunnel device have - sics.se requires at least # the address 3ffe:200:1:$PREFIX::2 IP6_ADDRS="3ffe:200:1:$PREFIX::2 3ffe:200:$PREFIX::1:1" # The /48 allocation that sics gives to you from 6bone address space. LOCALNET="3ffe:200:$PREFIX::/48" # The whole ipv6 internet INTERNET="2000::/3" # This tries to obtain your ip address automatically - set to your ip address if it seems to fail OWN_IP4="`ifconfig $DEV_IP4|grep 'inet addr'|sed -e 's/.*inet addr:\([0-9\.]\+\).*/\1/'`" # Bring up the ipv6 module - remove this if it is compiled statically to your kernel #modprobe ipv6 case $1 in start) if [ OWN_IP4 ]; then echo -n "Setting up inet6 device: "; else echo "No ipv4 address, exiting." && exit 0; exit 0 fi # Check if the device is already running ip tunnel | grep $DEV > /dev/null && echo "Device $DEV already running, exiting." && exit 1 # Bring the device up ip tunnel add $DEV mode sit remote $ENDPOINT local $OWN_IP4 ttl $TTL ip link set $DEV up mtu $MTU # Add the addresses to the device for I in $IP6_ADDRS do ip addr add $I dev $DEV done # Set the routes ip route add $INTERNET dev $DEV echo "$DEV." ;; stop) echo -n "Stopping inet6 device: " # Delete the routes and device ip route del $INTERNET dev $DEV ip tunnel del $DEV # Remove the ipv6 module #modprobe -r ipv6 echo "sics." ;; restart|force-reload) $0 stop sleep 1 $0 start ;; *) echo "Usage: $0 {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0