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.network
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
52 if [ "foo$2" = "foohotplug" ] && ! is_yes "${HOTPLUG}"; then
56 if [ "foo$2" = "foopcmcia-hotplug" ] && ! is_yes "${PCMCIA_HOTPLUG}"; then
62 # set all major variables
65 OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}"
67 if [ -x "$OTHERSCRIPT" ]; then
68 if is_yes "$DEFAULTHANDLING"; then
71 if [ "$HANDLING" = "0" ]; then
72 exec $OTHERSCRIPT $CONFIG $2
73 elif [ "$HANDLING" = "1" ]; then
74 $OTHERSCRIPT $CONFIG $2
78 # is this device available? (this catches PCMCIA devices for us)
79 if ! /sbin/ip link set multicast ${MULTICAST} dev ${DEVICE} > /dev/null 2>&1; then
80 nls "Delaying %s initialization" ${DEVICE}
84 if is_yes "$SLAVE" && [ -n "$MASTER" -a -x /sbin/ifenslave ]; then
85 RFLAG="" && is_yes "${RECIEVE-ONLY}" && RFLAG="-r"
87 ip link set ${DEVICE} down
88 nls "Enslaving %s to %s" "$DEVICE" "$MASTER"
89 ifenslave $RFLAG "$MASTER" "$DEVICE"
94 if [ -n "$MACADDR" ]; then
95 ip link set ${DEVICE} address ${MACADDR}
98 ip link set ${DEVICE} multicast ${MULTICAST} ${ARP} down
100 if [ -n "$MTU" ]; then
101 ip link set ${DEVICE} mtu ${MTU}
104 if is_yes "${IPV6_NETWORKING}" && is_yes "${IPV6_DISABLE_AUTOCONF}"; then
105 run_cmd "Disabling IPv6 autoconfiguration" sysctl -w net.ipv6.conf.${DEVICE}.autoconf=0
108 if is_wireless_device "${DEVICE}"; then
109 is_yes "${WLAN_UPEARLY}" && ip link set ${DEVICE} up
110 wireless_param ${DEVICE}
111 if is_yes "${WLAN_WPA}"; then
112 /usr/sbin/wpa_supplicant -B -w -D ${WLAN_WPA_DRIVER} -c ${WLAN_WPA_CONFIG} -i ${DEVICE} ${WLAN_WPA_OPTIONS} -P "/var/run/wpa_supplicant-${DEVICE}.pid"
116 if [ "$HANDLING" = "2" ]; then
120 if [ -n "$BOOTPROTO" -a "$BOOTPROTO" != "none" -a "$BOOTPROTO" != "static" ]; then
121 if is_yes "$IPV4_NETWORKING"; then
125 if [ -n "$DHCP_CLIENT" ]; then
126 if [ -z "$DHCP_HOSTNAME" ]; then
127 DHCP_HOSTNAME="$HOSTNAME"
129 case ${DHCP_CLIENT##*/} in
131 [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME"
132 DHCP_ARGS="$DHCP_ARGS -i $DEVICE"
135 [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME"
136 DHCP_ARGS="$DHCP_ARGS $DEVICE"
139 [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-H $DHCP_HOSTNAME"
140 DHCP_ARGS="$DHCP_ARGS $DEVICE"
143 # Can't specify a host with dhclient ?
148 DHCP_ARGS="$DHCP_OPTIONS $DHCP_ARGS"
150 if check_link_down ${DEVICE}; then
151 run_cmd "$(nls 'Determining IP information for %s (%s)' "$DEVICE" "${DHCP_CLIENT##*/}")" /bin/false
152 nls '%s: Check cable/radio on-off switch?' "$DEVICE"
156 if ! run_cmd "$(nls 'Determining IP information for %s (%s)' "$DEVICE" "${DHCP_CLIENT##*/}")" $DHCP_CLIENT $DHCP_ARGS; then
160 # give time for determining IP information
161 check_device_down && sleep 1 && check_device_down && sleep 3
162 check_device_down && ip link set ${DEVICE} up
166 if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}" ]; then
167 # If broadcast is missing then autocalculate it
168 if ! (echo $IP4ADDROPT | egrep -q "brd|broadcast"); then
169 IP4ADDROPT="brd + ${IP4ADDROPT}"
172 if [ -n "$REMIP" ]; then
173 ip addr add ${IP4ADDR} peer ${REMIP} dev ${DEVICE} ${IP4ADDROPT}
175 ip addr add ${IP4ADDR} dev ${DEVICE} ${IP4ADDROPT}
180 ip link set ${DEVICE} up
183 if is_yes "$IPV6_NETWORKING" && [ -n "${IP6ADDR}" ]; then
184 ip addr add ${IP6ADDR} dev ${DEVICE} ${IP6ADDROPT}
187 # IPv4/6 gateways and default routes
191 # device have to have ip address set before
192 if is_yes "$PROXYARP"; then
193 run_cmd "$(nls 'Enabling proxy ARP on %s' "${DEVICE}")" sysctl -w net.ipv4.conf.${DEVICE}.proxy_arp=1
196 if [ "$HANDLING" = "3" ]; then
200 if is_yes "$IPX"; then
201 /etc/sysconfig/network-scripts/ifup-ipx $DEVICE
204 if [ "$HANDLING" = "4" ]; then
208 exec /etc/sysconfig/network-scripts/ifup-post $CONFIG
210 # This must be last line !