3 # $Id: ifup,v 1.56 2001/05/15 16:03:44 baggins Exp $
5 PATH=/sbin:/usr/sbin:/bin:/usr/bin
7 . /etc/sysconfig/network
8 . /etc/rc.d/init.d/functions
9 . /etc/sysconfig/network-scripts/.functions
11 # Will be removed in the future
12 if is_yes "$NETWORKING" ; then
13 if [ -z "$IPV4_NETWORKING" ] ; then
14 echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!"
15 echo "Please upgrade your config"
16 echo "Assuming you want IPv4 networking"
18 export IPV4_NETWORKING
24 # device name must be ifcfg-somename
28 nls "usage: %s <device name>" "ifup" >&2
32 if [ `id -u` != 0 ]; then
33 if [ -x /sbin/usernetctl ]; then
34 exec /sbin/usernetctl $DEV up
36 nls "Users cannot control this device." >&2
40 if [ -f "/etc/sysconfig/interfaces/ifcfg-$DEV" ] ; then
41 CONFIG="/etc/sysconfig/interfaces/ifcfg-$DEV"
48 if [ "foo$2" = "fooboot" ] && is_no "${ONBOOT}"; then
54 # set all major variables
57 OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}"
59 if [ -x "$OTHERSCRIPT" ]; then
60 if [ "$HANDLING" = "0" ]; then
61 exec $OTHERSCRIPT $CONFIG $2
62 elif [ "$HANDLING" = "1" ]; then
63 $OTHERSCRIPT $CONFIG $2
67 # is this device available? (this catches PCMCIA devices for us)
68 if ! (/sbin/ip link set multicast ${MULTICAST} dev ${DEVICE} > /dev/null 2>&1); then
69 nls "Delaying %s initialization" ${DEVICE}
73 if is_yes "$SLAVE" && [ -n "$MASTER" -a -x /sbin/ifenslave ]; then
74 RFLAG="" && is_yes "${RECIEVE-ONLY}" && RFLAG="-r"
76 ip link set ${DEVICE} down
77 nls "Enslaving %s to %s" "$DEVICE" "$MASTER"
78 ifenslave $RFLAG "$MASTER" "$DEVICE"
83 if [ -n "$MACADDR" ]; then
84 ip link set ${DEVICE} address ${MACADDR}
87 ip link set ${DEVICE} multicast ${MULTICAST} arp ${ARP} down
89 if is_yes "${IPV6_NETWORKING}" && is_yes "${IPV6_DISABLE_AUTOCONF}"; then
90 run_cmd "Disabling IPv6 autoconfiguration" sysctl -w net.ipv6.conf.${DEVICE}=0
93 if [ "$HANDLING" = "2" ]; then
97 if [ -n "$BOOTPROTO" -a "$BOOTPROTO" != "none" ]; then
99 if is_yes "$IPV4_NETWORKING"; then
100 if [ "$BOOTPROTO" = "bootp" -o "$BOOTPROTO" = "pump" ]; then
101 DHCP_CLIENT=/sbin/pump
104 if [ -z "$DHCP_CLIENT" ]; then
105 if [ -x /sbin/dhcpcd ]; then
106 DHCP_CLIENT=/sbin/dhcpcd
107 elif [ -x /sbin/dhclient ]; then
108 DHCP_CLIENT=/sbin/dhclient
109 elif [ -x /sbin/dhcpxd ]; then
110 DHCP_CLIENT=/sbin/dhcpxd
111 elif [ -x /sbin/pump ]; then
112 DHCP_CLIENT=/sbin/pump
114 nls "Can't find a dhcp client."
120 if [ -n "$DHCP_CLIENT" ]; then
121 case $(basename $DHCP_CLIENT) in
123 [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME"
124 DHCP_ARGS="$DHCP_ARGS -i $DEVICE"
127 [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME"
128 DHCP_ARGS="$DHCP_ARGS $DEVICE"
131 [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-H $DHCP_HOSTNAME"
132 DHCP_ARGS="$DHCP_ARGS $DEVICE"
135 # Can't specify a host with dhclient ?
140 DHCP_ARGS="$DHCP_OPTIONS $DHCP_ARGS"
142 if ! run_cmd "$(nls 'Determining IP information for') $DEVICE ($(basename $DHCP_CLIENT))" $DHCP_CLIENT $DHCP_ARGS ; then
146 # give time for determining IP information
147 check_device_down && sleep 1 && check_device_down && sleep 3
148 check_device_down && ip link set ${DEVICE} up
154 if is_yes "$IPV4_NETWORKING" ; then
155 # If broadcast is missing then autocalculate it
156 if ! (echo $IP4ADDROPT | egrep -q "brd|broadcast"); then
157 IP4ADDROPT="brd + ${IP4ADDROPT}"
160 if [ -n "$REMIP" ]; then
161 ip addr add ${IP4ADDR} peer ${REMIP} dev ${DEVICE} ${IP4ADDROPT}
163 ip addr add ${IP4ADDR} dev ${DEVICE} ${IP4ADDROPT}
168 ip link set ${DEVICE} up
171 if is_yes "$IPV6_NETWORKING" ; then
172 ip addr add ${IP6ADDR} dev ${DEVICE} ${IP6ADDROPT}
175 # IPv4/6 gateways and default routes
179 if [ "$HANDLING" = "3" ]; then
183 if is_yes "$IPX"; then
184 /etc/sysconfig/network-scripts/ifup-ipx $DEVICE
187 if [ "$HANDLING" = "4" ]; then
191 exec /etc/sysconfig/network-scripts/ifup-post $CONFIG
193 # This must be last line !
194 # vi:syntax=sh:tw=78:ts=8:sw=4