3 # network Bring up/down networking
5 # chkconfig: 2345 10 90
6 # description: Activates/Deactivates all network interfaces configured to \
10 # $Id: network,v 1.22 1999/09/15 10:35:07 misiek Exp $
13 NLS_DOMAIN="rc-scripts"
15 # Source function library.
16 . /etc/rc.d/init.d/functions
17 . /etc/rc.d/init.d/functions.network
19 [ ! -f /etc/sysconfig/network ] && exit 0
21 . /etc/sysconfig/network
23 # Check that networking is up.
24 [ "${NETWORKING}" == "no" -o "${NETWORKING}" == "" ] && exit 0
26 [ -x /sbin/ip ] || exit 0
29 # initialize networking:
30 # - check IPv4, IPv6, IPX can be handled by system
31 # - setup default IPv{4,6} interfaces policy like:
33 # - spoofig protection,
34 # - icmp echo ignore broadcasts,
35 # - setup lo interface
38 # Set UP loopback interface
41 # Modprobe needed devices
48 proc_net ipv4/ip_forward start 1 0 IPV4_FORWARDING "IPv4 forwarding"
51 proc_net ipv6/conf/all/forwarding start 1 0 IPV6_FORWARDING "IPv6 forwarding"
59 # Set static ARP table
65 # deinitialize networking
66 # - down lo interface.
73 proc_net ipv6/conf/all/forwarding stop 1 0 IPV6_FORWARDING "IPv6 forwarding"
76 proc_net ipv4/ip_forward stop 1 0 IPV4_FORWARDING "IPv4 forwarding"
79 ipv4_anti_spoofing off
81 # Set DOWN loopback interface
85 # find all the interfaces besides loopback.
86 # ignore aliases, alternative configurations, and editor backup files
87 interfaces="`(cd /etc/sysconfig/interfaces && ls ifcfg* | \
88 egrep -v '(ifcfg-lo|:)' | egrep 'ifcfg-[a-z0-9]+$' | sed 's/^ifcfg-//g' | xargs) 2> /dev/null`"
89 interfaces_boot="`(cd /etc/sysconfig/interfaces && ls ifcfg* | \
90 egrep -v '(ifcfg-lo|ifcfg-sit|:)' | egrep 'ifcfg-[a-z0-9]+$' | \
91 xargs egrep -l "ONBOOT=[^n][^o]" | sed 's/^ifcfg-//g') 2> /dev/null`"
92 interfaces_sit_boot="`(cd /etc/sysconfig/interfaces && ls ifcfg-sit* | \
93 egrep 'ifcfg-[a-z0-9]+$' | xargs egrep -l "ONBOOT=[^n][^o]" | sed 's/^ifcfg-//g') 2> /dev/null`"
94 tunnels="`(cd /etc/sysconfig/interfaces && ls -1 tnlcfg-* | \
95 xargs egrep -l "ONBOOT=[^n][^o]" | sed 's/^tnlcfg-//g') 2> /dev/null`"
97 # See how we were called.
101 for i in $interfaces_boot $interfaces_sit_boot; do
105 for i in $tunnels; do
107 /sbin/ifup tnlcfg-$i boot
112 touch /var/lock/subsys/network
115 for i in $tunnels; do
116 /sbin/ifdown tnlcfg-$i boot
117 /sbin/tnldown $i boot
120 for i in $interfaces_sit_boot $interfaces_boot; do
125 rm -f /var/lock/subsys/network
128 nls "Configured devices:"
129 echo "lo $interfaces"
130 nls "Configured tunnels:"
133 nls "Currently active devices and tunnels:"
134 /sbin/ip link show | egrep '^[^ ].*' |sed 's/[0-9]*: \(.*\):.*/\1/'|xargs
141 echo "Usage: $0 {start|stop|restart|status}"