3 # network Bring up/down networking
5 # chkconfig: 2345 10 90
6 # description: Activates/Deactivates all network interfaces configured to \
13 PATH=/sbin:/usr/sbin:/bin:/usr/bin
16 NLS_DOMAIN="rc-scripts"
18 # Source function library.
19 . /etc/rc.d/init.d/functions
20 . /etc/sysconfig/network-scripts/functions.network
22 if [ ! -f /etc/sysconfig/network ]; then
23 nls "%s is missing. Can't continue." "/etc/sysconfig/network"
27 . /etc/sysconfig/network
29 # Check that networking is up.
30 is_no "${NETWORKING}" && exit 0
32 # Will be removed in the future
33 if is_yes "$NETWORKING" ; then
34 if [ -z "$IPV4_NETWORKING" ] ; then
35 echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!"
36 echo "Please upgrade your config"
37 echo "Assuming you want IPv4 networking"
42 if [ ! -x /sbin/ip ]; then
43 nls "%s is missing. Can't continue." "/sbin/ip"
48 # initialize networking:
49 # - check IPv4, IPv6, IPX can be handled by system
50 # - setup default IPv{4,6} interfaces policy like:
51 # - spoofig protection,
52 # - icmp echo ignore broadcasts,
53 # - setup lo interface
56 # Modprobe needed devices
59 # Setup interfaces names
60 [ -x /sbin/nameif -a -f /etc/mactab ] && run_cmd "Setting interfaces names (nameif)" /sbin/nameif
62 # Kernel network parameters
63 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
65 # Set UP loopback interface
73 if is_yes "$IPX"; then
74 if [ -n $IPXAUTOPRIMARY ] ; then
75 if is_yes "$IPXAUTOPRIMARY"; then
80 /sbin/ipx_configure --auto_primary=$IPXAUTOPRIMARY
82 if [ -n $IPXAUTOFRAME ] ; then
83 if is_yes "$IPXAUTOFRAME"; then
88 /sbin/ipx_configure --auto_interface=$IPXAUTOFRAME
90 if [ -n "$IPXINTERNALNETNUM" -a "$IPXINTERNALNETNUM" != "0" ]; then
91 /sbin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM
98 # Set static RARP table
101 # Set static ARP table
106 # deinitialize networking
107 # - down lo interface.
115 # Set DOWN loopback interface
119 # find all the interfaces besides loopback.
120 # ignore aliases, alternative configurations, and editor backup files
121 if [ -n "$(grep "^BOOTPRIO=" /etc/sysconfig/interfaces/ifcfg* 2> /dev/null)" ]; then
122 interfaces_boot=$(( \
123 . /etc/rc.d/init.d/functions; \
124 cd /etc/sysconfig/interfaces; \
125 egrep 'BOOTPRIO' ifcfg* | sort -t= -n -k2,2 | \
126 awk ' { gsub(/:BOOTPRIO.*/,NIL); print $0 } '| egrep -v 'ifcfg-lo' | \
128 ONBOOT=""; . /etc/sysconfig/interfaces/"$i"; is_yes "$ONBOOT" &&
131 awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
134 . /etc/rc.d/init.d/functions; \
135 cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \
136 egrep -v '(ifcfg-lo|ifcfg-sit|ifcfg-atm|ifcfg-lec|ifcfg-nas|ifcfg-br|ifcfg-(.*)\.(.*))' | \
137 LC_ALL=C egrep 'ifcfg-[a-z0-9\.]+$' | \
139 ONBOOT=""; . /etc/sysconfig/interfaces/"$i"; is_yes "$ONBOOT" && echo "$i"; \
141 awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
142 interfaces_vlan_boot=$((
143 . /etc/rc.d/init.d/functions; \
144 cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \
145 egrep 'ifcfg-(.*)\.(.*)' | \
146 LC_ALL=C egrep 'ifcfg-[a-z0-9\.]+$' | \
148 ONBOOT=""; . /etc/sysconfig/interfaces/"$i"; is_yes "$ONBOOT" && echo "$i"; \
150 awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
151 interfaces_br_boot=$((
152 . /etc/rc.d/init.d/functions; \
153 cd /etc/sysconfig/interfaces && ls -1 ifcfg-br* | \
154 LC_ALL=C egrep 'ifcfg-[a-z0-9\.]+$' | \
156 ONBOOT=""; . /etc/sysconfig/interfaces/"$i"; is_yes "$ONBOOT" && echo "$i"; \
158 awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
159 interfaces_sit_boot=$((
160 . /etc/rc.d/init.d/functions; \
161 cd /etc/sysconfig/interfaces && ls -1 ifcfg-sit* | \
162 LC_ALL=C egrep 'ifcfg-[a-z0-9]+$' | \
164 ONBOOT=""; . /etc/sysconfig/interfaces/"$i"; is_yes "$ONBOOT" && echo "$i"; \
166 awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
168 tunnels=$((cd /etc/sysconfig/interfaces && ls -1 tnlcfg-* | \
169 xargs egrep -l "ONBOOT=[^n][^o]" | \
170 LC_ALL=C egrep 'tnlcfg-[a-z0-9]+$' | \
171 awk ' { gsub(/tnlcfg-/,NIL); print $0 } ') 2> /dev/null)
173 # See how we were called.
176 rc_splash "bootnetwork start"
180 for i in $interfaces_boot $interfaces_vlan_boot $interfaces_sit_boot ; do
181 run_cmd -a "$(nls 'Bringing up interface %s' "$i")" /sbin/ifup $i boot
184 for i in $interfaces_br_boot ; do
185 run_cmd -a "$(nls 'Bringing up bridge interface %s' "$i")" /sbin/ifup $i boot
188 for i in $tunnels; do
189 run_cmd -a "$(nls 'Setting tunnel %s' "$i")" /sbin/tnlup $i boot
190 run_cmd -a "$(nls 'Bringing up tunnel interface %s' "$i")" /sbin/ifup tnlcfg-$i boot
195 touch /var/lock/subsys/network
198 # If we go to runlevel 0, 1 or 6 then umount all network fs
199 if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then
200 if [ -x /etc/rc.d/init.d/netfs -a -f /var/lock/subsys/netfs ];
202 /etc/rc.d/init.d/netfs stop
204 netmtab=$(awk '{ if ($3 ~ /^(nfs|smbfs|ncpfs|cifs)$/ ) print $3}' /proc/mounts)
205 if (echo "$netmtab" | grep -q nfs); then
206 run_cmd "Unmounting NFS filesystems" umount -fat nfs
208 if (echo "$netmtab" | grep -q smbfs); then
209 run_cmd "Unmounting SMB filesystems" umount -at smbfs
211 if (echo "$netmtab" | grep -q ncpfs); then
212 run_cmd "Unmounting NCP filesystems" umount -at ncpfs
214 if (echo "$netmtab" | grep -q cifs); then
215 run_cmd "Unmounting CIFS filesystems" umount -at cifs
220 for i in $tunnels; do
221 run_cmd -a "$(nls 'Shutting down tunnel interface %s' "$i")" /sbin/ifdown tnlcfg-$i boot
222 run_cmd -a "$(nls 'Removing tunnel %s' "$i")" /sbin/tnldown $i boot
225 for i in $interfaces_br_boot ; do
226 run_cmd -a "$(nls 'Shutting down bridge interface %s' "$i")" /sbin/ifdown $i boot
229 for i in $interfaces_sit_boot $interfaces_vlan_boot $interfaces_boot ; do
230 run_cmd -a "$(nls 'Shutting down interface %s' "$i")" /sbin/ifdown $i boot
235 rm -f /var/lock/subsys/network
238 nls "Configured devices:"
239 echo "lo $interfaces"
240 nls "Configured tunnels:"
243 nls "Currently inactive devices and tunnels:"
244 /sbin/ip link show | awk -F":" '(/^[0-90-90-9]:/) && ! (/UP/) { print $2 }' | xargs
245 nls "Currently active devices and tunnels:"
246 /sbin/ip link show | awk -F":" ' (/UP/) { print $2 }' | xargs
253 echo "Usage: $0 {start|stop|restart|status}"
259 # This must be last line !
260 # vi:syntax=sh:tw=78:ts=8:sw=4