#!/bin/sh # dhclient-script for Linux. Dan Halbert, March, 1997. # Updated for Linux 2.[12] by Brian J. Murrell, January 1999. # No guarantees about this. I'm a novice at the details of Linux # networking. # Pruned down for TiVo use, September 2001. Enhanced to allow for # use on 2.1.24 kernel, with pppd complexities, January 2002. # if [ x$new_broadcast_address != x ]; then new_broadcast_arg="broadcast $new_broadcast_address" fi if [ x$old_broadcast_address != x ]; then old_broadcast_arg="broadcast $old_broadcast_address" fi if [ x$new_subnet_mask != x ]; then new_subnet_arg="netmask $new_subnet_mask" fi if [ x$old_subnet_mask != x ]; then old_subnet_arg="netmask $old_subnet_mask" fi if [ x$alias_subnet_mask != x ]; then alias_subnet_arg="netmask $alias_subnet_mask" fi if [ x$reason = xMEDIUM ]; then # Linux doesn't do mediums (ok, ok, media). exit 0 fi if [ x$reason = xPREINIT ]; then if [ x$alias_ip_address != x ]; then # Bring down alias interface. Its routes will disappear too. ifconfig $interface:0- inet 0 fi ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \ broadcast 255.255.255.255 up # We need to give the kernel some time to get the interface up. sleep 1 # Add routes to make broadcast work. Do not omit netmask. route.tivo add default dev $interface netmask 0.0.0.0 route.tivo add -host 255.255.255.255 dev $interface route.tivo add -net 255.255.255.0 netmask 255.255.255.0 dev $interface sleep 1 exit 0 fi if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then exit 0 fi if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \ [ x$alias_ip_address != x$old_ip_address ]; then # Possible new alias. Remove old alias. ifconfig $interface:0- inet 0 fi if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then # IP address changed. Bringing down the interface will delete all routes, # and clear the ARP cache. ifconfig $interface inet down fi if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then ifconfig $interface inet $new_ip_address $new_subnet_arg \ $new_broadcast_arg # Add a network route to the computed network address. route.tivo add -net $new_network_number $new_subnet_arg dev $interface for router in $new_routers; do route.tivo add default gw $router done fi if [ x$reason = xREBIND ] && [ x$old_ip_address = x$new_ip_address ] && \ ! grep -q ppp0: /proc/net/dev || ! ( route.tivo -n | grep -q ^0.0.0.0 ) ; then # We're renewing, same IP address, there's no default route, and PPP isn't # up. pppd probably removed our previous default route. Put it back. # I'd rather do this via route metrics but they aren't sufficiently well # supported in 2.1.24 for router in $new_routers; do route.tivo add default gw $router netmask 0.0.0.0 done fi if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ]; then ifconfig $interface:0- inet 0 ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg route.tivo add -host $alias_ip_address $interface:0 fi exit 0 fi if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then if [ x$alias_ip_address != x ]; then # Turn off alias interface. ifconfig $interface:0- inet 0 fi if [ x$old_ip_address != x ]; then # Shut down interface, which will delete routes and clear arp cache. ifconfig $interface inet down # Bring the interface back up and make it suitable for broadcasting # requests again, as if we were in PREINIT phase. sleep 1 ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \ broadcast 255.255.255.255 up sleep 1 route.tivo add default dev $interface netmask 0.0.0.0 route.tivo add -host 255.255.255.255 dev $interface route.tivo add -net 255.255.255.0 netmask 255.255.255.0 dev $interface sleep 1 fi if [ x$alias_ip_address != x ]; then ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg route.tivo add -host $alias_ip_address $interface:0 fi exit 0 fi if [ x$reason = xTIMEOUT ]; then if [ x$alias_ip_address != x ]; then ifconfig $interface:0- inet 0 fi ifconfig $interface inet $new_ip_address $new_subnet_arg \ $new_broadcast_arg set $new_routers ############## what is -w in ping? if ping -q -c 1 $1; then if [ x$new_ip_address != x$alias_ip_address ] && \ [ x$alias_ip_address != x ]; then ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg route.tivo add -host $alias_ip_address dev $interface:0 fi route.tivo add -net $new_network_number for router in $new_routers; do route.tivo add default gw $router done exit 0 fi ifconfig $interface inet down # Bring the interface back up and make it suitable for broadcasting # requests again, as if we were in PREINIT phase. sleep 1 ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \ broadcast 255.255.255.255 up sleep 1 route.tivo add default dev $interface netmask 0.0.0.0 route.tivo add -host 255.255.255.255 dev $interface route.tivo add -net 255.255.255.0 netmask 255.255.255.0 dev $interface sleep 1 exit 1 fi exit 0