3 # network Bring up/down networking
5 # chkconfig: 2345 10 90
6 # description: Activates/Deactivates all network interfaces configured to \
11 if [ ! -f /etc/sysconfig/network ]; then
12 . /etc/rc.d/init.d/functions
13 nls "%s is missing. Can't continue." "/etc/sysconfig/network"
17 . /etc/sysconfig/network
19 # Source function library.
20 . /etc/rc.d/init.d/functions
21 . /lib/rc-scripts/functions.network
23 # Will be removed in the future
24 if [ -n "$NETWORKING" ] && is_yes "$NETWORKING"; then
25 if [ -z "$IPV4_NETWORKING" ]; then
26 echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!"
27 echo "Please upgrade your config"
28 echo "Assuming you want IPv4 networking"
34 # initialize networking:
35 # - check IPv4, IPv6, IPX can be handled by system
36 # - setup default IPv{4,6} interfaces policy like:
37 # - spoofig protection,
38 # - icmp echo ignore broadcasts,
39 # - setup lo interface
41 if [ ! -x /sbin/ip ]; then
42 nls "%s is missing. Can't continue." "/sbin/ip"
46 # Modprobe needed devices
52 # Setup interfaces names
53 if ! is_empty_file /etc/mactab && [ -x /sbin/nameif ]; then
54 run_cmd "Setting interfaces names (nameif)" /sbin/nameif
57 # Kernel network parameters
58 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
60 # Set UP loopback interface
68 if is_yes "$IPX"; then
69 if [ -n $IPXAUTOPRIMARY ] ; then
70 if is_yes "$IPXAUTOPRIMARY"; then
75 /sbin/ipx_configure --auto_primary=$IPXAUTOPRIMARY
77 if [ -n $IPXAUTOFRAME ] ; then
78 if is_yes "$IPXAUTOFRAME"; then
83 /sbin/ipx_configure --auto_interface=$IPXAUTOFRAME
85 if [ -n "$IPXINTERNALNETNUM" -a "$IPXINTERNALNETNUM" != "0" ]; then
86 /sbin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM
92 # Run this again to catch any interface-specific actions
95 # Set static RARP table
98 # Set static ARP table
103 # deinitialize networking
104 # - down lo interface.
111 # Set DOWN loopback interface
115 # Get list of interface configs
116 # ignores editor backup files and rpm backups
117 network_interface_configs() {
119 for a in /etc/sysconfig/interfaces/$match; do
121 *.rpmorig|*.rpmnew|*.rpmsave|*~|*.orig)
131 find_boot_interfaces() {
132 ifcfg_files="$(network_interface_configs 'ifcfg-*')"
133 bootprio=$(grep '^BOOTPRIO=' $ifcfg_files 2>/dev/null)
135 if [ -n "$bootprio" ]; then
136 # find all the interfaces besides loopback.
138 for a in $(echo "$bootprio" | sort -t= -s -n -k2,2); do
141 *ifcfg-lo) continue ;;
143 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
144 [ "${DEVICE:+set}" != "set" ] && continue
145 [ ${USERS:-no} != no ] && continue
146 is_yes ${ONBOOT:-no} && echo "${i##*/ifcfg-}"
151 for i in $ifcfg_files; do
153 ifcfg-lo|ifcfg-sit*|ifcfg-atm*|ifcfg-lec*|ifcfg-nas*|ifcfg-br*|ifcfg-macvlan*|ifcfg-macvtap*|ifcfg-*.*) continue ;;
155 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
156 [ "${DEVICE:+set}" != "set" ] && continue
157 [ ${USERS:-no} != no ] && continue
158 is_yes ${ONBOOT:-no} && echo "${i##*/ifcfg-}"
162 interfaces_vlan_boot=`
163 for i in $ifcfg_files; do
168 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
169 [ "${DEVICE:+set}" != "set" ] && continue
170 [ ${USERS:-no} != no ] && continue
171 is_yes ${ONBOOT:-no} && echo "${i##*/ifcfg-}"
176 for i in $ifcfg_files; do
181 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
182 [ "${DEVICE:+set}" != "set" ] && continue
183 [ ${USERS:-no} != no ] && continue
184 is_yes ${ONBOOT:-no} && echo "${i##*/ifcfg-}"
188 interfaces_virt_boot=`
189 for i in $ifcfg_files; do
191 ifcfg-macvtap*|ifcfg-macvlan*) ;;
194 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
195 [ "${DEVICE:+set}" != "set" ] && continue
196 [ ${USERS:-no} != no ] && continue
197 is_yes ${ONBOOT:-no} && echo "${i##*/ifcfg-}"
201 interfaces_sit_boot=`
202 for i in $ifcfg_files; do
207 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
208 [ "${DEVICE:+set}" != "set" ] && continue
209 [ ${USERS:-no} != no ] && continue
210 is_yes ${ONBOOT:-no} && echo "${i##*/ifcfg-}"
216 for i in $(network_interface_configs 'tnlcfg-*'); do
217 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
218 [ "${DEVICE:+set}" != "set" ] && continue
219 [ ${USERS:-no} != no ] && continue
220 is_yes ${ONBOOT:-no} && echo "${i##*/tnlcfg-}"
226 rc_splash "bootnetwork start"
229 for i in $interfaces_boot $interfaces_vlan_boot $interfaces_sit_boot; do
230 run_cmd -a "$(nls 'Bringing up interface %s' "$i")" /sbin/ifup $i boot
233 for i in $interfaces_br_boot ; do
234 run_cmd -a "$(nls 'Bringing up bridge interface %s' "$i")" /sbin/ifup $i boot
237 for i in $interfaces_virt_boot ; do
238 run_cmd -a "$(nls 'Bringing up virtual interface %s' "$i")" /sbin/ifup $i boot
241 for i in $tunnels; do
242 run_cmd -a "$(nls 'Setting tunnel %s' "$i")" /sbin/tnlup $i boot
243 run_cmd -a "$(nls 'Bringing up tunnel interface %s' "$i")" /sbin/ifup tnlcfg-$i boot
248 touch /var/lock/subsys/network
252 # If we go to runlevel 0, 1 or 6 then umount all network fs
253 if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then
254 if [ -x /etc/rc.d/init.d/netfs -a -f /var/lock/subsys/netfs ];
256 /etc/rc.d/init.d/netfs stop
260 for i in $tunnels; do
261 run_cmd -a "$(nls 'Shutting down tunnel interface %s' "$i")" /sbin/ifdown tnlcfg-$i boot
262 run_cmd -a "$(nls 'Removing tunnel %s' "$i")" /sbin/tnldown $i boot
265 for i in $interfaces_virt_boot ; do
266 run_cmd -a "$(nls 'Shutting down virtual interface %s' "$i")" /sbin/ifup $i boot
269 for i in $interfaces_br_boot ; do
270 run_cmd -a "$(nls 'Shutting down bridge interface %s' "$i")" /sbin/ifdown $i boot
273 for i in $interfaces_sit_boot $interfaces_vlan_boot $interfaces_boot ; do
274 run_cmd -a "$(nls 'Shutting down interface %s' "$i")" /sbin/ifdown $i boot
279 rm -f /var/lock/subsys/network >/dev/null 2>&1
282 # Reload all active interfaces
284 if [ ! -f /var/lock/subsys/network ]; then
285 msg_not_running network
292 # if no DHCP client found we can't reload anything
293 if [ -z "$DHCP_CLIENT" ]; then
298 case ${DHCP_CLIENT##*/} in
312 echo "Reloading using $DHCP_CLIENT DHCP Client is not implmemented in rc-scripts"
318 # for IPv4 DHCP interfaces send signal to refresh interface
319 local dev devs=${*:-$(/sbin/ip link show | awk -F: '/UP/{print $2}')}
321 if [ ! -f /etc/sysconfig/interfaces/ifcfg-$dev ]; then
324 . /etc/sysconfig/interfaces/ifcfg-$dev
326 if [ -n "$BOOTPROTO" -a "$BOOTPROTO" != "none" -a "$BOOTPROTO" != "static" ] && is_yes "$IPV4_NETWORKING"; then
327 case ${DHCP_CLIENT##*/} in
329 DHCP_ARGS="$DHCP_ARGS -i $DEVICE"
332 DHCP_ARGS="$DHCP_ARGS $DEVICE"
335 DHCP_ARGS="$DHCP_ARGS $DEVICE"
338 DHCP_ARGS="$DHCP_ARGS $DEVICE"
341 DHCP_ARGS="$DHCP_OPTIONS $DHCP_ARGS"
343 show 'Reloading interface %s' $dev
344 if $DHCP_CLIENT $DHCP_ARGS; then
356 # See how we were called.
366 touch /var/lock/subsys/network
370 rm -f /var/lock/subsys/network
377 nls "Configured devices:"
378 echo "lo $interfaces"
379 nls "Configured tunnels:"
382 nls "Currently inactive devices and tunnels:"
383 /sbin/ip link show | awk -F":" '(/^[0-90-90-9]:/) && ! (/UP/) { print $2 }' | xargs
384 nls "Currently active devices and tunnels:"
385 /sbin/ip link show | awk -F":" ' (/UP/) { print $2 }' | xargs
399 msg_usage "$0 {start|stop|reload|restart|status}"