3 # network Bring up/down networking
5 # chkconfig: 2345 10 90
6 # description: Activates/Deactivates all network interfaces configured to \
11 if [ ! -f /etc/sysconfig/network ]; then
12 . /etc/rc.d/init.d/functions
13 nls "%s is missing. Can't continue." "/etc/sysconfig/network"
17 . /etc/sysconfig/network
19 # Source function library.
20 . /etc/rc.d/init.d/functions
21 . /lib/rc-scripts/functions.network
23 # Will be removed in the future
24 if [ -n "$NETWORKING" ] && is_yes "$NETWORKING"; then
25 if [ -z "$IPV4_NETWORKING" ]; then
26 echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!"
27 echo "Please upgrade your config"
28 echo "Assuming you want IPv4 networking"
34 # initialize networking:
35 # - check IPv4, IPv6, IPX can be handled by system
36 # - setup default IPv{4,6} interfaces policy like:
37 # - spoofig protection,
38 # - icmp echo ignore broadcasts,
39 # - setup lo interface
41 if [ ! -x /sbin/ip ]; then
42 nls "%s is missing. Can't continue." "/sbin/ip"
46 # Modprobe needed devices
52 # Setup interfaces names
53 if ! is_empty_file /etc/mactab && [ -x /sbin/nameif ]; then
54 run_cmd "Setting interfaces names (nameif)" /sbin/nameif
57 # Kernel network parameters
58 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
60 # Set UP loopback interface
68 if is_yes "$IPX"; then
69 if [ -n $IPXAUTOPRIMARY ] ; then
70 if is_yes "$IPXAUTOPRIMARY"; then
75 /sbin/ipx_configure --auto_primary=$IPXAUTOPRIMARY
77 if [ -n $IPXAUTOFRAME ] ; then
78 if is_yes "$IPXAUTOFRAME"; then
83 /sbin/ipx_configure --auto_interface=$IPXAUTOFRAME
85 if [ -n "$IPXINTERNALNETNUM" -a "$IPXINTERNALNETNUM" != "0" ]; then
86 /sbin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM
92 # Run this again to catch any interface-specific actions
95 # Set static RARP table
98 # Set static ARP table
103 # deinitialize networking
104 # - down lo interface.
111 # Set DOWN loopback interface
115 # Get list of interface configs
116 # ignores editor backup files and rpm backups
117 network_interface_configs() {
119 for a in /etc/sysconfig/interfaces/$match; do
121 *.rpmorig|*.rpmnew|*.rpmsave|*~|*.orig)
131 find_boot_interfaces() {
132 ifcfg_files="$(network_interface_configs 'ifcfg-*')"
133 bootprio=$(grep '^BOOTPRIO=' $ifcfg_files)
135 if [ -n "$bootprio" ]; then
136 # find all the interfaces besides loopback.
138 for a in $(echo "$bootprio" | sort -t= -s -n -k2,2); do
141 *ifcfg-lo) continue ;;
143 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
144 [ "${DEVICE:+set}" != "set" ] && continue
145 [ ${USERS:-no} != no ] && continue
146 [ ${ONBOOT:-no} = yes ] && echo "${i##*/ifcfg-}"
151 for i in $ifcfg_files; do
153 ifcfg-lo|ifcfg-sit*|ifcfg-atm*|ifcfg-lec*|ifcfg-nas*|ifcfg-br*|ifcfg-macvlan*|ifcfg-macvtap*|ifcfg-*.*) continue ;;
155 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
156 [ "${DEVICE:+set}" != "set" ] && continue
157 [ ${USERS:-no} != no ] && continue
158 [ ${ONBOOT:-no} = yes ] && echo "${i##*/ifcfg-}"
162 interfaces_vlan_boot=`
163 for i in $ifcfg_files; do
168 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
169 [ "${DEVICE:+set}" != "set" ] && continue
170 [ ${USERS:-no} != no ] && continue
171 [ ${ONBOOT:-no} = yes ] && echo "${i##*/ifcfg-}"
176 for i in $ifcfg_files; do
181 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
182 [ "${DEVICE:+set}" != "set" ] && continue
183 [ ${USERS:-no} != no ] && continue
184 [ ${ONBOOT:-no} = yes ] && echo "${i##*/ifcfg-}"
188 interfaces_virt_boot=`
189 for i in $ifcfg_files; do
191 ifcfg-macvtap*|ifcfg-macvlan*) ;;
194 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
195 [ "${DEVICE:+set}" != "set" ] && continue
196 [ ${USERS:-no} != no ] && continue
197 [ ${ONBOOT:-no} = yes ] && echo "${i##*/ifcfg-}"
201 interfaces_sit_boot=`
202 for i in $ifcfg_files; do
207 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
208 [ "${DEVICE:+set}" != "set" ] && continue
209 [ ${USERS:-no} != no ] && continue
210 [ ${ONBOOT:-no} = yes ] && echo "${i##*/ifcfg-}"
216 for i in $(network_interface_configs 'tnlcfg-*'); do
217 DEVICE=""; ONBOOT=""; USERS=""; . "$i" 2>/dev/null
218 [ "${DEVICE:+set}" != "set" ] && continue
219 [ ${USERS:-no} != no ] && continue
220 [ ${ONBOOT:-no} = yes ] && echo "${i##*/tnlcfg-}"
226 emit pld.network-starting
227 emit starting JOB=network
229 rc_splash "bootnetwork start"
232 for i in $interfaces_boot $interfaces_vlan_boot $interfaces_sit_boot; do
233 run_cmd -a "$(nls 'Bringing up interface %s' "$i")" /sbin/ifup $i boot
236 for i in $interfaces_br_boot ; do
237 run_cmd -a "$(nls 'Bringing up bridge interface %s' "$i")" /sbin/ifup $i boot
240 for i in $interfaces_virt_boot ; do
241 run_cmd -a "$(nls 'Bringing up virtual interface %s' "$i")" /sbin/ifup $i boot
244 for i in $tunnels; do
245 run_cmd -a "$(nls 'Setting tunnel %s' "$i")" /sbin/tnlup $i boot
246 run_cmd -a "$(nls 'Bringing up tunnel interface %s' "$i")" /sbin/ifup tnlcfg-$i boot
251 touch /var/lock/subsys/network
252 emit --no-wait pld.network-started
253 emit --no-wait started JOB=network
257 emit pld.network-stopping
258 emit stopping JOB=network
259 # If we go to runlevel 0, 1 or 6 then umount all network fs
260 if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then
261 if [ -x /etc/rc.d/init.d/netfs -a -f /var/lock/subsys/netfs ];
263 /etc/rc.d/init.d/netfs stop
267 for i in $tunnels; do
268 run_cmd -a "$(nls 'Shutting down tunnel interface %s' "$i")" /sbin/ifdown tnlcfg-$i boot
269 run_cmd -a "$(nls 'Removing tunnel %s' "$i")" /sbin/tnldown $i boot
272 for i in $interfaces_virt_boot ; do
273 run_cmd -a "$(nls 'Shutting down virtual interface %s' "$i")" /sbin/ifup $i boot
276 for i in $interfaces_br_boot ; do
277 run_cmd -a "$(nls 'Shutting down bridge interface %s' "$i")" /sbin/ifdown $i boot
280 for i in $interfaces_sit_boot $interfaces_vlan_boot $interfaces_boot ; do
281 run_cmd -a "$(nls 'Shutting down interface %s' "$i")" /sbin/ifdown $i boot
286 rm -f /var/lock/subsys/network >/dev/null 2>&1
287 emit --no-wait pld.network-stopped
288 emit --no-wait stopped JOB=network
291 # Reload all active interfaces
293 if [ ! -f /var/lock/subsys/network ]; then
294 msg_not_running network
301 # if no DHCP client found we can't reload anything
302 if [ -z "$DHCP_CLIENT" ]; then
307 case ${DHCP_CLIENT##*/} in
321 echo "Reloading using $DHCP_CLIENT DHCP Client is not implmemented in rc-scripts"
327 # for IPv4 DHCP interfaces send signal to refresh interface
328 local dev devs=${*:-$(/sbin/ip link show | awk -F: '/UP/{print $2}')}
330 if [ ! -f /etc/sysconfig/interfaces/ifcfg-$dev ]; then
333 . /etc/sysconfig/interfaces/ifcfg-$dev
335 if [ -n "$BOOTPROTO" -a "$BOOTPROTO" != "none" -a "$BOOTPROTO" != "static" ] && is_yes "$IPV4_NETWORKING"; then
336 case ${DHCP_CLIENT##*/} in
338 DHCP_ARGS="$DHCP_ARGS -i $DEVICE"
341 DHCP_ARGS="$DHCP_ARGS $DEVICE"
344 DHCP_ARGS="$DHCP_ARGS $DEVICE"
347 DHCP_ARGS="$DHCP_ARGS $DEVICE"
350 DHCP_ARGS="$DHCP_OPTIONS $DHCP_ARGS"
352 show 'Reloading interface %s' $dev
353 if $DHCP_CLIENT $DHCP_ARGS; then
365 # See how we were called.
368 if is_yes "$VSERVER_ISOLATION_NET"; then
369 emit pld.network-starting
370 emit starting JOB=network
371 touch /var/lock/subsys/network
372 emit pld.network-started
373 emit --no-wait started JOB=network
384 touch /var/lock/subsys/network
388 rm -f /var/lock/subsys/network
391 if is_yes "$VSERVER_ISOLATION_NET"; then
392 emit pld.network-stopping
393 emit stopping JOB=network
394 rm -f /var/lock/subsys/network >/dev/null 2>&1
395 emit pld.network-stopped
396 emit --no-wait stopped JOB=network
404 nls "Configured devices:"
405 echo "lo $interfaces"
406 nls "Configured tunnels:"
409 nls "Currently inactive devices and tunnels:"
410 /sbin/ip link show | awk -F":" '(/^[0-90-90-9]:/) && ! (/UP/) { print $2 }' | xargs
411 nls "Currently active devices and tunnels:"
412 /sbin/ip link show | awk -F":" ' (/UP/) { print $2 }' | xargs
416 if is_yes "$VSERVER_ISOLATION_NET"; then
424 if is_yes "$VSERVER_ISOLATION_NET"; then
433 msg_usage "$0 {start|stop|reload|restart|status}"