3 # network Bring up/down networking
5 # chkconfig: 2345 10 90
6 # description: Activates/Deactivates all network interfaces configured to \
12 if [ ! -f /etc/sysconfig/network ]; then
13 . /etc/rc.d/init.d/functions
14 nls "%s is missing. Can't continue." "/etc/sysconfig/network"
18 . /etc/sysconfig/network
20 # Source function library.
21 . /etc/rc.d/init.d/functions
22 . /lib/rc-scripts/functions.network
24 # Will be removed in the future
25 if [ -n "$NETWORKING" ] && is_yes "$NETWORKING"; then
26 if [ -z "$IPV4_NETWORKING" ]; then
27 echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!"
28 echo "Please upgrade your config"
29 echo "Assuming you want IPv4 networking"
35 # initialize networking:
36 # - check IPv4, IPv6, IPX can be handled by system
37 # - setup default IPv{4,6} interfaces policy like:
38 # - spoofig protection,
39 # - icmp echo ignore broadcasts,
40 # - setup lo interface
42 if [ ! -x /sbin/ip ]; then
43 nls "%s is missing. Can't continue." "/sbin/ip"
47 # Modprobe needed devices
50 # Setup interfaces names
51 if [ -x /sbin/nameif -a -f /etc/mactab -a -x /usr/bin/wc ] && [ $(grep -vsE '^(#| *$)' /etc/mactab | wc -l) -gt 0 ]; then
52 run_cmd "Setting interfaces names (nameif)" /sbin/nameif
55 # Kernel network parameters
56 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
58 # Set UP loopback interface
66 if is_yes "$IPX"; then
67 if [ -n $IPXAUTOPRIMARY ] ; then
68 if is_yes "$IPXAUTOPRIMARY"; then
73 /sbin/ipx_configure --auto_primary=$IPXAUTOPRIMARY
75 if [ -n $IPXAUTOFRAME ] ; then
76 if is_yes "$IPXAUTOFRAME"; then
81 /sbin/ipx_configure --auto_interface=$IPXAUTOFRAME
83 if [ -n "$IPXINTERNALNETNUM" -a "$IPXINTERNALNETNUM" != "0" ]; then
84 /sbin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM
90 # Set static RARP table
93 # Set static ARP table
98 # deinitialize networking
99 # - down lo interface.
106 # Set DOWN loopback interface
110 # Get list of interface configs
111 # ignores editor backup files and rpm backups
112 network_interface_configs() {
114 for a in /etc/sysconfig/interfaces/$match; do
116 *.rpmorig|*.rpmnew|*.rpmsave|*~|*.orig)
126 find_boot_interfaces() {
127 ifcfg_files="$(network_interface_configs 'ifcfg-*')"
128 bootprio=$(grep '^BOOTPRIO=' $ifcfg_files)
130 if [ -n "$bootprio" ]; then
131 # find all the interfaces besides loopback.
133 for a in $(echo "$bootprio" | sort -t= -n -k2,2); do
136 *ifcfg-lo) continue ;;
138 ONBOOT=""; . "$i" 2>/dev/null
139 [ ${ONBOOT:-no} = yes ] && echo "${i##*/ifcfg-}"
144 for i in $ifcfg_files; do
146 ifcfg-lo|ifcfg-sit*|ifcfg-atm*|ifcfg-lec*|ifcfg-nas*|ifcfg-br*|ifcfg-*.*) continue ;;
148 ONBOOT=""; . "$i" 2>/dev/null
149 [ ${ONBOOT:-no} = yes ] && echo "${i##*/ifcfg-}"
153 interfaces_vlan_boot=`
154 for i in $ifcfg_files; do
159 ONBOOT=""; . "$i" 2>/dev/null
160 [ ${ONBOOT:-no} = yes ] && echo "${i##*/ifcfg-}"
165 for i in $ifcfg_files; do
170 ONBOOT=""; . "$i" 2>/dev/null
171 [ ${ONBOOT:-no} = yes ] && echo "${i##*/ifcfg-}"
175 interfaces_sit_boot=`
176 for i in $ifcfg_files; do
181 ONBOOT=""; . "$i" 2>/dev/null
182 [ ${ONBOOT:-no} = yes ] && echo "${i##*/ifcfg-}"
188 for i in $(network_interface_configs 'tnlcfg-*'); do
189 ONBOOT=""; . "$i" 2>/dev/null
190 [ ${ONBOOT:-no} = yes ] && echo "${i##*/tnlcfg-}"
196 emit pld.network-starting
197 rc_splash "bootnetwork start"
200 for i in $interfaces_boot $interfaces_vlan_boot $interfaces_sit_boot; do
201 run_cmd -a "$(nls 'Bringing up interface %s' "$i")" /sbin/ifup $i boot
204 for i in $interfaces_br_boot ; do
205 run_cmd -a "$(nls 'Bringing up bridge interface %s' "$i")" /sbin/ifup $i boot
208 for i in $tunnels; do
209 run_cmd -a "$(nls 'Setting tunnel %s' "$i")" /sbin/tnlup $i boot
210 run_cmd -a "$(nls 'Bringing up tunnel interface %s' "$i")" /sbin/ifup tnlcfg-$i boot
215 touch /var/lock/subsys/network
216 emit --no-wait pld.network-started
220 emit pld.network-stopping
221 # If we go to runlevel 0, 1 or 6 then umount all network fs
222 if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then
223 if [ -x /etc/rc.d/init.d/netfs -a -f /var/lock/subsys/netfs ];
225 /etc/rc.d/init.d/netfs stop
229 for i in $tunnels; do
230 run_cmd -a "$(nls 'Shutting down tunnel interface %s' "$i")" /sbin/ifdown tnlcfg-$i boot
231 run_cmd -a "$(nls 'Removing tunnel %s' "$i")" /sbin/tnldown $i boot
234 for i in $interfaces_br_boot ; do
235 run_cmd -a "$(nls 'Shutting down bridge interface %s' "$i")" /sbin/ifdown $i boot
238 for i in $interfaces_sit_boot $interfaces_vlan_boot $interfaces_boot ; do
239 run_cmd -a "$(nls 'Shutting down interface %s' "$i")" /sbin/ifdown $i boot
244 rm -f /var/lock/subsys/network >/dev/null 2>&1
245 emit --no-wait pld.network-stopped
248 # Reload all active interfaces
250 if [ ! -f /var/lock/subsys/network ]; then
251 msg_not_running network
258 # if no DHCP client found we can't reload anything
259 if [ -z "$DHCP_CLIENT" ]; then
264 case ${DHCP_CLIENT##*/} in
278 echo "Reloading using $DHCP_CLIENT DHCP Client is not implmemented in rc-scripts"
284 # for IPv4 DHCP interfaces send signal to refresh interface
285 local dev devs=${*:-$(/sbin/ip link show | awk -F: '/UP/{print $2}')}
287 if [ ! -f /etc/sysconfig/interfaces/ifcfg-$dev ]; then
290 . /etc/sysconfig/interfaces/ifcfg-$dev
292 if [ -n "$BOOTPROTO" -a "$BOOTPROTO" != "none" -a "$BOOTPROTO" != "static" ] && is_yes "$IPV4_NETWORKING"; then
293 case ${DHCP_CLIENT##*/} in
295 DHCP_ARGS="$DHCP_ARGS -i $DEVICE"
298 DHCP_ARGS="$DHCP_ARGS $DEVICE"
301 DHCP_ARGS="$DHCP_ARGS $DEVICE"
304 DHCP_ARGS="$DHCP_ARGS $DEVICE"
307 DHCP_ARGS="$DHCP_OPTIONS $DHCP_ARGS"
309 show 'Reloading interface %s' $dev
310 if $DHCP_CLIENT $DHCP_ARGS; then
322 # See how we were called.
325 if is_yes "$VSERVER_ISOLATION_NET"; then
326 emit pld.network-starting
327 touch /var/lock/subsys/network
328 emit pld.network-started
335 if is_yes "$VSERVER_ISOLATION_NET"; then
336 emit pld.network-stopping
337 rm -f /var/lock/subsys/network >/dev/null 2>&1
338 emit pld.network-stopped
345 nls "Configured devices:"
346 echo "lo $interfaces"
347 nls "Configured tunnels:"
350 nls "Currently inactive devices and tunnels:"
351 /sbin/ip link show | awk -F":" '(/^[0-90-90-9]:/) && ! (/UP/) { print $2 }' | xargs
352 nls "Currently active devices and tunnels:"
353 /sbin/ip link show | awk -F":" ' (/UP/) { print $2 }' | xargs
357 if is_yes "$VSERVER_ISOLATION_NET"; then
365 if is_yes "$VSERVER_ISOLATION_NET"; then
374 msg_usage "$0 {start|stop|reload|restart|status}"