blob: efd98cf15d7693076844f04553c480824ce4c480 [file] [log] [blame]
Glenn L McGrath419eed72002-08-21 14:24:38 +00001#!/bin/sh
Denys Vlasenko9c192e72017-04-06 00:53:43 +02002# Sample udhcpc renew script
Glenn L McGrath419eed72002-08-21 14:24:38 +00003
Russ Dill61fb4892002-10-14 21:41:28 +00004RESOLV_CONF="/etc/udhcpc/resolv.conf"
Glenn L McGrath419eed72002-08-21 14:24:38 +00005
6[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
7[ -n "$subnet" ] && NETMASK="netmask $subnet"
8
9/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
10
11if [ -n "$router" ]
12then
13 echo "deleting routers"
14 while /sbin/route del default gw 0.0.0.0 dev $interface
15 do :
16 done
17
Eric Andersen1aee3ff2004-10-13 07:18:05 +000018 metric=0
Glenn L McGrath419eed72002-08-21 14:24:38 +000019 for i in $router
20 do
Denys Vlasenko9c192e72017-04-06 00:53:43 +020021 if [ "$subnet" = "255.255.255.255" ]; then
22 # special case for /32 subnets:
23 # /32 instructs kernel to always use routing for all outgoing packets
24 # (they can never be sent to local subnet - there is no local subnet for /32).
25 # Used in datacenters, avoids the need for private ip-addresses between two hops.
26 /sbin/ip route add $i dev $interface
27 fi
Eric Andersen1aee3ff2004-10-13 07:18:05 +000028 /sbin/route add default gw $i dev $interface metric $((metric++))
Glenn L McGrath419eed72002-08-21 14:24:38 +000029 done
30fi
31
Denys Vlasenko9c192e72017-04-06 00:53:43 +020032# Only replace resolv.conf if we have at least one DNS server
Denys Vlasenko2e66dac2014-01-13 13:38:53 +010033if [ -n "$dns" ]
34then
35 echo -n > $RESOLV_CONF
36 [ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF
37 for i in $dns
38 do
39 echo adding dns $i
40 echo nameserver $i >> $RESOLV_CONF
41 done
42fi