#!/bin/sh #---------------------------------------------------------------------------- # /etc/ppp/ip-up - called whenever a (i)ppp connection has been come up # # Creation: 29.03.2000 fm # Last Update: $Id$ #---------------------------------------------------------------------------- run_ip_up () { case $interface in ppp0) # it's DSL, map interface case $tty in "" | eth*| br* | /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 >/var/run/pppoe.up ;; esac ;; esac echo $local >/var/run/$interface.ip # store my own ip address # # default route is either # default via dev # or # default dev def_gateway="" def_route=`ip route show | grep ^default` route_dev= route_gw="" if [ "$def_route" ]; then set $def_route case $# in 3) route_dev=$3 ;; 5) route_gw=$3 route_dev=$5 ;; *) logger -t "ip-up[$$]" "Unknown route format '$def_route'" ;; esac 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 logger -t "ip-up[$$]" "default route interface '$interface' comes up" is_default_route='yes' > /var/run/online [ -f /var/run/$interface.gw ] && read def_gateway < /var/run/$interface.gw : ${def_gateway:=""} if [ "$route_dev" ] then if [ "$route_dev" != "$default_route_interface" -o \ "$route_gw" != "$def_gateway" ]; then logger -t "ip-up[$$]" "changing default route from $route_gw:$route_dev to $def_gateway:$interface" case $def_gateway in "") ip route change default dev $real_interface ;; *) ip route change via $def_gateway ;; esac fi else ip route add default dev $real_interface fi else is_default_route='no' fi if [ -f /var/run/imond.pid ] then /usr/local/bin/imond-stat "$real_interface up $local" fi # Call all custom ip-ups for j in /etc/ppp/ip-up[0-9][0-9][0-9].* do if [ -f $j ] then logger -t "ip-up[$$]" "executing $j" . $j fi done if [ ! -f /var/run/ip-up.ppp-once ] then for j in /etc/ppp-once/ip-up[0-9][0-9][0-9].* do if [ -f $j ] then . $j fi done fi } script_op=up . /etc/ppp/ip-up-down