3 # network Bring up/down networking
6 # description: Activates/Deactivates all network interfaces configured to \
10 # Source function library.
11 . /etc/rc.d/init.d/functions
13 if [ ! -f /etc/sysconfig/network ]; then
17 . /etc/sysconfig/network
19 if [ -f /etc/sysconfig/pcmcia ]; then
20 . /etc/sysconfig/pcmcia
23 if [ -f /etc/sysconfig/network-ip6 ]; then
24 . /etc/sysconfig/network-ip6
27 # Check that networking is up.
28 [ ${NETWORKING} = "no" ] && exit 0
30 [ -x /sbin/ifconfig ] || exit 0
34 if [ ${IP6NETWORKING} = "yes" ]; then
35 if [ -r /lib/modules/`uname -r`/ipv6/ipv6.o ]; then
36 /sbin/modprobe net-pf-10
40 # Even if IPX is configured, without the utilities we can't do much
41 [ ! -x /usr/bin/ipx_internal_net -o ! -x /usr/bin/ipx_configure ] && IPX=
43 cd /etc/sysconfig/network-scripts
45 # find all the interfaces besides loopback.
46 # ignore aliases, alternative configurations, and editor backup files
47 interfaces=`ls ifcfg* | egrep -v '(ifcfg-lo|:)' | egrep 'ifcfg-[a-z0-9]+$' | \
52 # Turn IP forwarding on or off. We do this before bringing up the
53 # interfaces to make sure we don't forward when we shouldn't, and
54 # we do it even if networking isn't configured (why not?).
55 if [ -d /proc/sys/net/ipv4 ]; then
56 # people could have left this out of their kernel, which isn't
58 if [ ! -f /proc/sys/net/ipv4/ip_forward ] ; then
59 echo "/proc/sys/net/ipv4/ip_forward is missing --" \
60 "cannot control IP forwarding" >&2
62 if [ "$FORWARD_IPV4" = "no" -o "$FORWARD_IPV4" = "false" ]; then
64 message="Disabling IPv4 packet forwarding."
67 message="Enabling IPv4 packet forwarding."
70 if [ $value != `cat /proc/sys/net/ipv4/ip_forward` ]; then
73 echo "$value" > /proc/sys/net/ipv4/ip_forward
81 ipv4_spoof_protection ()
83 # This is the best method: turn on Source Address Verification and get
84 # spoof protection on all current and future interfaces.
85 if [ -e /proc/sys/net/ipv4/conf/all/rp_filter ]; then
86 show Setting up IP spoofing protection
88 for f in /proc/sys/net/ipv4/conf/*/rp_filter; do
96 echo "PROBLEMS SETTING UP IP SPOOFING PROTECTION. BE WORRIED!"
100 # See how we were called.
109 /usr/bin/ipx_configure --auto_primary=$IPXAUTOPRIMARY \
110 --auto_interface=$IPXAUTOFRAME
111 /usr/bin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM
115 for i in $interfaces; do
119 ipv4_spoof_protection
121 touch /var/lock/subsys/network
124 for i in $interfaces; do
129 /usr/bin/ipx_internal_net del
133 echo "Disabling IPv4 packet forwarding."
134 echo 0 > /proc/sys/net/ipv4/ip_forward
135 rm -f /var/lock/subsys/network
138 echo "Configured devices:"
141 if [ -x /bin/linuxconf ] ; then
142 eval `/bin/linuxconf --hint netdev`
143 echo "Devices that are down:"
145 echo "Devices with modified configuration:"
148 echo "Currently active devices:"
149 echo `/sbin/ifconfig | grep ^[a-z] | awk '{print $1}'`
157 if [ -x /bin/linuxconf ] ; then
158 eval `/bin/linuxconf --hint netdev`
159 if [ "$RECONF_IPV4ROUTING" = "yes" ] ; then
162 for device in $DEV_UP ; do
165 for device in $DEV_DOWN ; do
168 for device in $DEV_RECONF ; do
172 for device in $DEV_RECONF_ALIASES ; do
173 /etc/sysconfig/network-scripts/ifup-aliases $device
175 for device in $DEV_RECONF_ROUTES ; do
176 /etc/sysconfig/network-scripts/ifup-routes $device
178 case $IPX in yes|true)
179 case $IPXINTERNALNET in
181 /usr/bin/ipx_internal_net del
182 /usr/bin/ipx_internal_net add $IPXINTERNALNETNUM \
186 /usr/bin/ipx_internal_net add $IPXINTERNALNETNUM \
190 /usr/bin/ipx_internal_net del
200 if [ -x /bin/linuxconf ] ; then
201 eval `/bin/linuxconf --hint netdev`
202 [ -n "$DEV_UP$DEV_DOWN$DEV_RECONF$DEV_RECONF_ALIASES" -o \
203 -n "$DEV_RECONF_ROUTES$IPXINTERNALNET" -o \
204 "$RECONF_IPV4ROUTING" = yes ] && \
208 # if linuxconf isn't around to figure stuff out for us,
209 # we punt. Probably better than completely reloading
210 # networking if user isn't sure which to do. If user
211 # is sure, they would run restart or reload, not probe.
216 echo "Usage: network {start|stop|restart|reload|status|probe}"