3 # network Bring up/down networking
5 # chkconfig: 2345 10 90
6 # description: Activates/Deactivates all network interfaces configured to \
11 # $Id: network,v 1.53 2002/03/29 08:45:14 wojrus Exp $
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
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:
52 # - spoofig protection,
53 # - icmp echo ignore broadcasts,
54 # - setup lo interface
57 # Modprobe needed devices
60 # Kernel network parameters
61 run_cmd "Setting network parameters" sysctl -p /etc/sysctl.conf
63 # Set UP loopback interface
72 if is_yes "$IPX"; then
73 if [ -n $IPXAUTOPRIMARY ] ; then
74 if is_yes "$IPXAUTOPRIMARY"; then
79 /sbin/ipx_configure --auto_primary=$IPXAUTOPRIMARY
81 if [ -n $IPXAUTOFRAME ] ; then
82 if is_yes "$IPXAUTOFRAME"; then
87 /sbin/ipx_configure --auto_interface=$IPXAUTOFRAME
89 if [ -n "$IPXINTERNALNETNUM" -a "$IPXINTERNALNETNUM" != "0" ]; then
90 /sbin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM
97 # Set static RARP table
100 # Set static ARP table
105 # deinitialize networking
106 # - 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 interfaces=$((cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \
122 egrep -v '(ifcfg-lo|:)' | egrep 'ifcfg-[a-z0-9]+$' | \
123 awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
124 interfaces_boot=$((cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \
125 egrep -v '(ifcfg-lo|ifcfg-sit|ifcfg-atm|ifcfg-lec|ifcfg-nas|:)' | egrep 'ifcfg-[a-z0-9\.]+$' | \
126 xargs egrep -l "ONBOOT=[^n][^o]" | \
127 awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
128 interfaces_sit_boot=$((cd /etc/sysconfig/interfaces && ls -1 ifcfg-sit* | \
129 egrep 'ifcfg-[a-z0-9]+$' | xargs egrep -l "ONBOOT=[^n][^o]" | \
130 awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
131 tunnels=$((cd /etc/sysconfig/interfaces && ls -1 tnlcfg-* | \
132 xargs egrep -l "ONBOOT=[^n][^o]" | \
133 awk ' { gsub(/tnlcfg-/,NIL); print $0 } ') 2> /dev/null)
135 # See how we were called.
140 for i in $interfaces_boot $interfaces_sit_boot ; do
141 run_cmd -a "$(nls 'Bringing up interface') $i" /sbin/ifup $i boot
144 for i in $(find_ldap_interfaces) ; do
145 run_cmd -a "$(nls 'Bringing up interface from LDAP') $i" /sbin/ifup $i boot
148 for i in $tunnels; do
149 run_cmd -a "$(nls 'Setting tunnel') $i" /sbin/tnlup $i boot
150 run_cmd -a "$(nls 'Bringing up tunnel interface') $i" /sbin/ifup tnlcfg-$i boot
155 touch /var/lock/subsys/network
158 # If we go to runlevel 0, 1 or 6 then umount all network fs
159 if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then
160 if [ -x /etc/rc.d/init.d/netfs -a -f /var/lock/subsys/netfs ];
162 /etc/rc.d/init.d/netfs stop
164 netmtab=$(awk '{ if ($3 ~ /^(nfs|smbfs|ncpfs)$/ ) print $3}' /proc/mounts)
165 if (echo "$netmtab" | grep -q nfs); then
166 run_cmd "Unmounting NFS filesystems" umount -fat nfs
168 if (echo "$netmtab" | grep -q smbfs); then
169 run_cmd "Unmounting SMB filesystems" umount -at smbfs
171 if (echo "$netmtab" | grep -q ncpfs); then
172 run_cmd "Unmounting NCP filesystems" umount -at ncpfs
177 for i in $tunnels; do
178 run_cmd -a "$(nls 'Shutting down tunnel interface') $i" /sbin/ifdown tnlcfg-$i boot
179 run_cmd -a "$(nls 'Removing tunnel') $i" /sbin/tnldown $i boot
182 for i in $(find_ldap_interfaces) ; do
183 run_cmd -a "$(nls 'Shutting down interface from LDAP') $i" /sbin/ifdown $i boot
186 for i in $interfaces_sit_boot $interfaces_boot ; do
187 run_cmd -a "$(nls 'Shutting down interface') $i" /sbin/ifdown $i boot
192 rm -f /var/lock/subsys/network
195 nls "Configured devices:"
196 echo "lo $interfaces"
197 nls "Configured tunnels:"
200 nls "Currently inactive devices and tunnels:"
201 /sbin/ip link show | awk -F":" '(/^[0-90-90-9]:/) && ! (/UP/) { print $2 }' | xargs
202 nls "Currently active devices and tunnels:"
203 /sbin/ip link show | awk -F":" ' (/UP/) { print $2 }' | xargs
210 echo "Usage: $0 {start|stop|restart|status}"
216 # This must be last line !
217 # vi:syntax=sh:tw=78:ts=8:sw=4