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"
42 elif [ -f "/etc/sysconfig/interfaces/$DEV" ]; then
43 CONFIG="/etc/sysconfig/interfaces/$DEV"
50 if [ "foo$2" = "fooboot" ] && is_no "${ONBOOT}"; then
54 if [ "foo$2" = "foohotplug" ] && ! is_yes "${HOTPLUG}"; then
58 if [ "foo$2" = "foopcmcia-hotplug" ] && ! is_yes "${PCMCIA_HOTPLUG}"; then
64 # set all major variables
67 OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}"
69 if [ -x "$OTHERSCRIPT" ]; then
70 if is_yes "$DEFAULTHANDLING"; then
73 if [ "$HANDLING" = "0" ]; then
74 exec $OTHERSCRIPT $CONFIG $2
75 elif [ "$HANDLING" = "1" ]; then
76 $OTHERSCRIPT $CONFIG $2
80 if [ -n "$MACVLAN_DEV" -a -n "$MACVLAN_MACADDR" ]; then
81 ip link del link ${MACVLAN_DEV} ${DEVICE} type macvlan > /dev/null 2>&1
82 ip link add link ${MACVLAN_DEV} address ${MACVLAN_MACADDR} ${DEVICE} type macvlan
85 # is this device available? (this catches PCMCIA devices for us)
86 if ! /sbin/ip link set multicast ${MULTICAST} dev ${DEVICE} > /dev/null 2>&1; then
87 nls "Delaying %s initialization" ${DEVICE}
91 if is_yes "$SLAVE" && [ ! -x /sbin/ifenslave ]; then
92 nls "%s is missing. Can't continue." "/sbin/ifenslave"
96 if is_yes "$SLAVE" && [ -n "$MASTER" -a -x /sbin/ifenslave ]; then
97 RFLAG="" && is_yes "${RECIEVE-ONLY}" && RFLAG="-r"
99 ip link set ${DEVICE} down
100 nls "Enslaving %s to %s" "$DEVICE" "$MASTER"
101 ifenslave $RFLAG "$MASTER" "$DEVICE"
106 if [ -n "$MACADDR" ]; then
107 ip link set ${DEVICE} address ${MACADDR}
110 ip link set ${DEVICE} multicast ${MULTICAST} ${ARP} down
112 if [ -n "$MTU" ]; then
113 ip link set ${DEVICE} mtu ${MTU}
116 if is_yes "${IPV6_NETWORKING}" && is_yes "${IPV6_DISABLE_AUTOCONF}"; then
117 run_cmd "Disabling IPv6 autoconfiguration" sysctl -w net.ipv6.conf.${DEVICE}.autoconf=0
120 if is_wireless_device "${DEVICE}"; then
121 is_yes "${WLAN_UPEARLY}" && ip link set ${DEVICE} up
122 wireless_param ${DEVICE}
125 if is_yes "${WLAN_WPA}"; then
126 /usr/sbin/wpa_supplicant -D ${WLAN_WPA_DRIVER:-wext} -c ${WLAN_WPA_CONFIG:-/etc/wpa_supplicant.conf} -i ${DEVICE} ${WLAN_WPA_OPTIONS} -P "/var/run/wpa_supplicant-${DEVICE}.pid" -B
127 [ -z "$WLAN_WPA_WAIT_TIMEOUT" ] && WLAN_WPA_WAIT_TIMEOUT=15
128 # check_link_down sleeps for 0.5s
129 check_link_down ${DEVICE} $(( $WLAN_WPA_WAIT_TIMEOUT * 2 ))
132 if [ "$HANDLING" = "2" ]; then
136 if [ -n "$BOOTPROTO" -a "$BOOTPROTO" != "none" -a "$BOOTPROTO" != "static" ]; then
137 if is_yes "$IPV4_NETWORKING"; then
141 if [ -n "$DHCP_CLIENT" ]; then
142 if [ -z "$DHCP_HOSTNAME" ]; then
143 DHCP_HOSTNAME="$HOSTNAME"
145 case ${DHCP_CLIENT##*/} in
147 [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME"
148 DHCP_ARGS="$DHCP_ARGS -i $DEVICE"
151 [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME"
152 DHCP_ARGS="$DHCP_ARGS $DEVICE"
153 if is_no "$ZEROCONF"; then
154 DHCP_ARGS="$DHCP_ARGS --noipv4ll"
158 [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-H $DHCP_HOSTNAME"
159 DHCP_ARGS="$DHCP_ARGS $DEVICE"
162 # Can't specify a host with dhclient ?
166 DHCP_ARGS="-D $DEVICE"
170 DHCP_ARGS="$DHCP_OPTIONS $DHCP_ARGS"
172 if check_link_down ${DEVICE}; then
173 run_cmd "$(nls 'Determining IP information for %s (%s)' "$DEVICE" "${DHCP_CLIENT##*/}")" /bin/false
174 nls '%s: Check cable/radio on-off switch?' "$DEVICE"
178 if ! run_cmd "$(nls 'Determining IP information for %s (%s)' "$DEVICE" "${DHCP_CLIENT##*/}")" $DHCP_CLIENT $DHCP_ARGS; then
182 # give time for determining IP information
183 check_device_down && sleep 1 && check_device_down && sleep 3
184 check_device_down && ip link set ${DEVICE} up
188 if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}" ]; then
189 # If broadcast is missing then autocalculate it
190 if ! (echo $IP4ADDROPT | grep -qE "brd|broadcast"); then
191 IP4ADDROPT="brd + ${IP4ADDROPT}"
194 if [ -n "${SUBDEVICE}" ]; then
195 ALIAS="label ${SUBDEVICE}"
198 if [ -n "$REMIP" ]; then
199 ip addr add ${IP4ADDR} peer ${REMIP} ${ALIAS} dev ${DEVICE} ${IP4ADDROPT}
201 ip addr add ${IP4ADDR} ${ALIAS} dev ${DEVICE} ${IP4ADDROPT}
206 ip link set ${DEVICE} up
209 if is_yes "$IPV6_NETWORKING" && [ -n "${IP6ADDR}" ]; then
210 ip addr add ${IP6ADDR} dev ${DEVICE} ${IP6ADDROPT}
211 if [ -n "${IP6ADDRLABEL}" ]; then
212 ip addrlabel add prefix ${IP6ADDR} dev ${DEVICE} label ${IP6ADDRLABEL}
216 if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}" -a -x /sbin/arping ]; then
217 # update ARP cache of neighbouring computers
218 /sbin/arping -q -A -c 1 -I ${DEVICE} ${IP4ADDR%/*}
219 ( sleep 2; /sbin/arping -q -U -c 1 -I ${DEVICE} ${IP4ADDR%/*} ) > /dev/null 2>&1 < /dev/null &
222 # IPv4/6 gateways and default routes
226 # device have to have ip address set before
227 if is_yes "$PROXYARP"; then
228 run_cmd "$(nls 'Enabling proxy ARP on %s' "${DEVICE}")" sysctl -w net.ipv4.conf.${DEVICE}.proxy_arp=1
231 if [ "$HANDLING" = "3" ]; then
235 if is_yes "$IPX"; then
236 /etc/sysconfig/network-scripts/ifup-ipx $DEVICE
239 if is_yes "$ENABLE_6TO4"; then
240 # find an usable IPv4 address for this device; might have been obtained by dhcp or ppp
241 for ipv4 in `/sbin/ip addr show dev $DEVICE | awk -F'[ /]+' '/ inet /{print $3}'`; do
242 if [ `ipcalc -n $ipv4/8` != "NETWORK=10.0.0.0" \
243 -a `ipcalc -n $ipv4/12` != "NETWORK=172.16.0.0" \
244 -a `ipcalc -n $ipv4/24` != "NETWORK=192.168.0.0" \
245 -a `ipcalc -n $ipv4/24` != "NETWORK=169.254.0.0" ]; then
247 local_ipv6=`printf "2002:%02x%02x:%02x%02x::1" $(echo $ipv4 | tr . ' ')`
251 if [ -n "$local_ipv4" ]; then # we have an usable IPv4 address; set up the tunnel
252 tun6to4=tun6to4_$DEVICE
253 /sbin/ip tunnel add $tun6to4 mode sit ttl 128 remote any local $local_ipv4
254 /sbin/ip link set dev $tun6to4 up
255 /sbin/ip -6 addr add $local_ipv6/16 dev $tun6to4
256 /sbin/ip -6 route add 2000::/3 via ::192.88.99.1 dev $tun6to4 metric 1
260 if [ "$HANDLING" = "4" ]; then
264 exec /etc/sysconfig/network-scripts/ifup-post $CONFIG