#!/bin/sh #---------------------------------------------------------------------------- # /etc/ppp/ipv6-up - called whenever a (i)ppp connection has appeared # # Creation: 26.09.2009 zone42 # Last Update: $Id$ #---------------------------------------------------------------------------- run_ipv6pre_up () { case $interface in ppp0) # it's DSL, map interface case $tty in "" | eth*| br* | bond* | /dev/ttyp0 | /dev/ttyS[0-4] | /dev/ttyUSB[0-4] | /dev/capi/0 | /dev/ttyACM0 | /dev/ttyHS[0-3] | /dev/gsmmodem ) # empty: PPPoE, eth[0-9] in_kernel, else PPTP interface=pppoe # kristov: pppoe-status cannot currently handle a dual-stack IPv4+IPv6 connection properly >/var/run/pppoe.up ;; esac ;; *) >/var/run/$interface.up ;; esac # # default route is either # default via dev # or # default dev def_gateway= def_route=`ip -6 route show | grep ^default` route_dev= route_gw= if [ "$def_route" ] then regex_dev='^default\>.*\[[:space:]]*\([^[:space:]]\+\).*' route_dev=$(echo "$def_route" | grep "$regex_dev" | sed -e "s/$regex_dev/\1/") regex_gw='^default\>.*\[[:space:]]*\([^[:space:]]\+\).*' route_gw=$(echo "$def_route" | grep "$regex_gw" | sed -e "s/$regex_gw/\1/") fi if [ -f /etc/default-route-interface ] # default route existing? then read default_route_interface < /etc/default-route-interface else default_route_interface=$route_dev case $default_route_interface in ppp0) default_route_interface=pppoe ;; esac fi if [ "$default_route_interface" = "$interface" ] then echo "default route interface '$interface' comes up" is_default_route='yes' echo $interface > /var/run/online.ipv6 if [ "$route_dev" ] then if [ "$route_dev" != "$default_route_interface" -o \ "$route_gw" != "$def_gateway" ]; then echo "changing default route from ${route_gw:-}:$route_dev to ${def_gateway:-}:$interface" case $def_gateway in "") ip -6 route change default dev $real_interface ;; *) ip -6 route change via $def_gateway ;; esac fi else ip -6 route add default dev $real_interface fi else is_default_route='no' fi # kristov: imond cannot currently handle a dual-stack IPv4+IPv6 connection properly if [ -f /var/run/imond.pid ] then /usr/local/bin/imond-stat "$real_interface up $local" fi # Call all custom ipv6-ups for j in /etc/ppp/ipv6pre-up[0-9][0-9][0-9].* do if [ -f $j ] then echo "executing $j" . $j fi done if [ ! -f /var/run/ipv6pre-up.ppp-once ] then for j in /etc/ppp-once/ipv6pre-up[0-9][0-9][0-9].* do if [ -f $j ] then echo "executing $j" . $j fi done fi } ip=ipv6pre script_op=up . /etc/ppp/ip-up-down