Difference between revisions of "IPv6 tunnel broker setup"

From ArchWiki
Jump to: navigation, search
(Created page with "Hurricane Electric offers a free [http://tunnelbroker.net/ tunnel broker] service that is relatively painless to use under Arch if you wish to add IPv6 connectivity to an IPv4-on...")
 
(Tunnel rc.d script)
Line 4: Line 4:
  
 
== Tunnel rc.d script ==
 
== Tunnel rc.d script ==
 +
 +
Try the following init script to start and stop an IPv6 tunnel once you have registered it with HE. I placed this at <tt>/etc/rc.d/6in4-tunnel</tt>. Obviously some of the variables up top will need to be filled in.
 +
 +
<pre>
 +
#!/bin/bash
 +
 +
if_name=he6in4
 +
server_ipv4='' # HE Server Endpoint IP
 +
client_ipv4='' # Your local IP
 +
client_ipv6='' # Your HE-assigned client IP
 +
link_mtu=1480
 +
tunnel_ttl=255
 +
 +
daemon_name=6in4-tunnel
 +
 +
. /etc/rc.conf
 +
. /etc/rc.d/functions
 +
 +
case "$1" in
 +
  start)
 +
    stat_busy "Starting $daemon_name daemon"
 +
 +
    ifconfig $if_name &>/dev/null
 +
    if [ $? -eq 0 ]; then
 +
      stat_busy "Interface $if_name already exists"
 +
      stat_fail
 +
      exit 1
 +
    fi
 +
 +
    ip tunnel add $if_name mode sit remote $server_ipv4 local $client_ipv4 ttl $tunnel_ttl
 +
    ip link set $if_name up mtu $link_mtu
 +
    ip addr add $client_ipv6 dev $if_name
 +
    ip route add ::/0 dev $if_name
 +
 +
    add_daemon $daemon_name
 +
    stat_done
 +
    ;;
 +
 +
  stop)
 +
    stat_busy "Stopping $daemon_name daemon"
 +
 +
    ifconfig $if_name &>/dev/null
 +
    if [ $? -ne 0 ]; then
 +
      stat_busy "Interface $if_name does not exist"
 +
      stat_fail
 +
      exit 1
 +
    fi
 +
 +
    ip link set $if_name down
 +
    ip tunnel del $if_name
 +
 +
    rm_daemon $daemon_name
 +
    stat_done
 +
    ;;
 +
 +
  *)
 +
    echo "usage: $0 {start|stop}"
 +
esac
 +
exit 0
 +
</pre>

Revision as of 00:40, 19 October 2010

Hurricane Electric offers a free tunnel broker service that is relatively painless to use under Arch if you wish to add IPv6 connectivity to an IPv4-only host.

Registering for a tunnel

Tunnel rc.d script

Try the following init script to start and stop an IPv6 tunnel once you have registered it with HE. I placed this at /etc/rc.d/6in4-tunnel. Obviously some of the variables up top will need to be filled in.

#!/bin/bash

if_name=he6in4
server_ipv4='' # HE Server Endpoint IP
client_ipv4='' # Your local IP
client_ipv6='' # Your HE-assigned client IP
link_mtu=1480
tunnel_ttl=255

daemon_name=6in4-tunnel

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
  start)
    stat_busy "Starting $daemon_name daemon"

    ifconfig $if_name &>/dev/null
    if [ $? -eq 0 ]; then
      stat_busy "Interface $if_name already exists"
      stat_fail
      exit 1
    fi

    ip tunnel add $if_name mode sit remote $server_ipv4 local $client_ipv4 ttl $tunnel_ttl
    ip link set $if_name up mtu $link_mtu
    ip addr add $client_ipv6 dev $if_name
    ip route add ::/0 dev $if_name

    add_daemon $daemon_name
    stat_done
    ;;

  stop)
    stat_busy "Stopping $daemon_name daemon"

    ifconfig $if_name &>/dev/null
    if [ $? -ne 0 ]; then
      stat_busy "Interface $if_name does not exist"
      stat_fail
      exit 1
    fi

    ip link set $if_name down
    ip tunnel del $if_name

    rm_daemon $daemon_name
    stat_done
    ;;

  *)
    echo "usage: $0 {start|stop}"
esac
exit 0