#
# probe: true
-# $Id: network,v 1.41 2000/11/17 06:25:52 kloczek Exp $
+# $Id: network,v 1.58 2002/12/17 14:01:10 baggins Exp $
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
# NLS
NLS_DOMAIN="rc-scripts"
# Source function library.
. /etc/rc.d/init.d/functions
-. /etc/sysconfig/network-scripts/.functions
+. /etc/sysconfig/network-scripts/functions.network
-[ ! -f /etc/sysconfig/network ] && exit 0
+if [ ! -f /etc/sysconfig/network ]; then
+ nls "%s is missing. Can't continue." "/etc/sysconfig/network"
+ exit 1
+fi
. /etc/sysconfig/network
# Check that networking is up.
is_no "${NETWORKING}" && exit 0
-[ -x /sbin/ip ] || exit 0
+# Will be removed in the future
+if is_yes "$NETWORKING" ; then
+ if [ -z "$IPV4_NETWORKING" ] ; then
+ echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!"
+ echo "Please upgrade your config"
+ echo "Assuming you want IPv4 networking"
+ IPV4_NETWORKING=yes
+ fi
+fi
+
+if [ ! -x /sbin/ip ]; then
+ nls "%s is missing. Can't continue." "/sbin/ip"
+ exit 1
+fi
######
# initialize networking:
# - check IPv4, IPv6, IPX can be handled by system
# - setup default IPv{4,6} interfaces policy like:
-# - forwarding,
# - spoofig protection,
# - icmp echo ignore broadcasts,
# - setup lo interface
network_init()
{
-# Set UP loopback interface
-set_up_loopback
-
# Modprobe needed devices
modprobe_net
-# Spoofing protection && dynamic IP && port range
-ipv4_anti_spoofing on
-ipv4_dynamic_ip_patch on
-ipv4_local_port_range on
+# Kernel network parameters
+run_cmd "Setting network parameters" sysctl -p /etc/sysctl.conf
-# Others proc/sys/net
-proc_networking start
+# Set UP loopback interface
+set_up_loopback
-# Setup NAT rules
+# Setup configuration
setup_nat on
setup_routes on
-
+setup_ip_rules on
# Setup IPX
if is_yes "$IPX"; then
- if [ ! -z $IPXAUTOPRIMARY ] ; then
- /usr/bin/ipx_configure --auto_primary=$IPXAUTOPRIMARY
+ if [ -n $IPXAUTOPRIMARY ] ; then
+ if is_yes "$IPXAUTOPRIMARY"; then
+ IPXAUTOPRIMARY="on"
+ else
+ IPXAUTOPRIMARY="off"
+ fi
+ /sbin/ipx_configure --auto_primary=$IPXAUTOPRIMARY
fi
- if [ ! -z $IPXAUTOFRAME ] ; then
- /usr/bin/ipx_configure --auto_interface=$IPXAUTOFRAME
+ if [ -n $IPXAUTOFRAME ] ; then
+ if is_yes "$IPXAUTOFRAME"; then
+ IPXAUTOFRAME="on"
+ else
+ IPXAUTOFRAME="off"
+ fi
+ /sbin/ipx_configure --auto_interface=$IPXAUTOFRAME
fi
- if [ ! -z "$IPXINTERNALNETNUM" -a "$IPXINTERNALNETNUM" != "0" ]; then
- /usr/bin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM
+ if [ -n "$IPXINTERNALNETNUM" -a "$IPXINTERNALNETNUM" != "0" ]; then
+ /sbin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM
fi
fi
}
network_postinit()
{
+# Set static RARP table
+static_rarp
+
# Set static ARP table
static_arp
-
-# Start rdisc daemon
-rdisc on
}
######
network_deinit()
{
setup_routes off
+setup_ip_rules off
# Set down NAT rules
setup_nat off
-
-# Shut down rdisc daemon
-rdisc off
-
-# Spoofing protection && dynamic IP && port range
-ipv4_anti_spoofing off
-ipv4_dynamic_ip_patch off
-ipv4_local_port_range off
-
-# Others proc/sys/net
-proc_networking stop
-
# Set DOWN loopback interface
set_down_loopback
}
-proc_networking()
-{
-TODO="$1"
-
-# IPv4 forwarding
-proc_net ipv4/ip_forward $TODO 1 0 IPV4_FORWARDING "IPv4 forwarding"
-# IPv6 forwarding
-if is_yes "$IPV6_NETWORKING"; then
- proc_net ipv6/conf/all/forwarding $TODO 1 0 IPV6_FORWARDING "IPv6 forwarding"
-fi
-# Others proc/net
-proc_net ipv4/conf/all/accept_redirects $TODO 1 0 IPV4_ACCEPT_ICMP_REDIR ""
-proc_net ipv4/conf/all/accept_source_route $TODO 1 1 IPV4_ACCEPT_SOURCE_ROUTE ""
-proc_net ipv4/conf/all/log_martians $TODO 1 0 IPV4_LOG_MARTIANS ""
-proc_net ipv4/conf/all/mc_forwarding $TODO 1 0 IPV4_MULTICAST ""
-proc_net ipv4/conf/all/proxy_arp $TODO 1 0 IPV4_PROXY_ARP ""
-proc_net ipv4/conf/all/secure_redirects $TODO 1 1 IPV4_ACCEPT_ICMP_REDIR_GATE ""
-proc_net ipv4/conf/all/send_redirects $TODO 1 1 IPV4_SEND_ICMP_REDIR ""
-proc_net ipv4/icmp_echo_ignore_all $TODO 1 0 IPV4_IGN_ALL_ICMP ""
-proc_net ipv4/icmp_echo_ignore_broadcasts $TODO 1 1 IPV4_IGN_CAST_ICMP ""
-proc_net ipv4/ip_no_pmtu_disc $TODO 1 0 IPV4_MTU_DISCOVERY ""
-proc_net ipv4/ip_masq_debug $TODO 1 0 IPV4_MASQ_DEBUGGING ""
-proc_net ipv4/tcp_retrans_collapse $TODO 0 1 IPV4_RETRANS_COLLAPSE ""
-proc_net ipv4/tcp_sack $TODO 0 1 IPV4_NO_SELECT_ACK ""
-proc_net ipv4/tcp_timestamps $TODO 0 1 IPV4_NO_TIMESTAMPS ""
-proc_net ipv4/tcp_stdurg $TODO 1 0 IPV4_RFC793 ""
-proc_net ipv4/tcp_syncookies $TODO 1 0 IPV4_SYN_COOKIES ""
-proc_net ipv4/tcp_window_scaling $TODO 1 0 IPV4_NO_WINDOW_SCALING ""
-# ... and proc/net/ipv6 goodies
-proc_net ipv6/conf/default/autoconf $TODO 0 1 IPV6_AUTOCONF ""
-proc_net ipv6/conf/default/autoconf_route $TODO 0 1 IPV6_AUTOCONF_ROUTE ""
-}
-
# find all the interfaces besides loopback.
# ignore aliases, alternative configurations, and editor backup files
-
-interfaces=$( (cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \
- egrep -v '(ifcfg-lo|:)' | egrep 'ifcfg-[a-z0-9]+$' | \
- awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
-interfaces_boot=$( (cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \
- egrep -v '(ifcfg-lo|ifcfg-sit|ifcfg-atm|ifcfg-lec|:)' | egrep 'ifcfg-[a-z0-9]+$' | \
- xargs egrep -l "ONBOOT=[^n][^o]" | \
+interfaces_boot=$((
+ . /etc/rc.d/init.d/functions; \
+ cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \
+ egrep -v '(ifcfg-lo|ifcfg-sit|ifcfg-atm|ifcfg-lec|ifcfg-nas|:)' | \
+ egrep 'ifcfg-[a-z0-9\.]+$' | \
+ for i in `cat`; do \
+ ONBOOT=""; . /etc/sysconfig/interfaces/"$i"; is_yes "$ONBOOT" && echo "$i"; \
+ done | \
awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
-interfaces_sit_boot=$( (cd /etc/sysconfig/interfaces && ls -1 ifcfg-sit* | \
- egrep 'ifcfg-[a-z0-9]+$' | xargs egrep -l "ONBOOT=[^n][^o]" | \
+interfaces_sit_boot=$((
+ . /etc/rc.d/init.d/functions; \
+ cd /etc/sysconfig/interfaces && ls -1 ifcfg-sit* | \
+ egrep 'ifcfg-[a-z0-9]+$' | \
+ for i in `cat`; do \
+ ONBOOT=""; . /etc/sysconfig/interfaces/"$i"; is_yes "$ONBOOT" && echo "$i"; \
+ done | \
awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null)
-tunnels=$( (cd /etc/sysconfig/interfaces && ls -1 tnlcfg-* | \
+tunnels=$((cd /etc/sysconfig/interfaces && ls -1 tnlcfg-* | \
xargs egrep -l "ONBOOT=[^n][^o]" | \
awk ' { gsub(/tnlcfg-/,NIL); print $0 } ') 2> /dev/null)
network_init
for i in $interfaces_boot $interfaces_sit_boot ; do
- /sbin/ifup $i boot
- done
-
- for i in `find_ldap_interfaces` ; do
- /sbin/ifup $i boot
+ run_cmd -a "$(nls 'Bringing up interface') $i" /sbin/ifup $i boot
done
for i in $tunnels; do
- /sbin/tnlup $i boot
- /sbin/ifup tnlcfg-$i boot
+ run_cmd -a "$(nls 'Setting tunnel') $i" /sbin/tnlup $i boot
+ run_cmd -a "$(nls 'Bringing up tunnel interface') $i" /sbin/ifup tnlcfg-$i boot
done
network_postinit
touch /var/lock/subsys/network
;;
stop)
- for i in $tunnels; do
- /sbin/ifdown tnlcfg-$i boot
- /sbin/tnldown $i boot
- done
+ # If we go to runlevel 0, 1 or 6 then umount all network fs
+ if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then
+ if [ -x /etc/rc.d/init.d/netfs -a -f /var/lock/subsys/netfs ];
+ then
+ /etc/rc.d/init.d/netfs stop
+ else
+ netmtab=$(awk '{ if ($3 ~ /^(nfs|smbfs|ncpfs)$/ ) print $3}' /proc/mounts)
+ if (echo "$netmtab" | grep -q nfs); then
+ run_cmd "Unmounting NFS filesystems" umount -fat nfs
+ fi
+ if (echo "$netmtab" | grep -q smbfs); then
+ run_cmd "Unmounting SMB filesystems" umount -at smbfs
+ fi
+ if (echo "$netmtab" | grep -q ncpfs); then
+ run_cmd "Unmounting NCP filesystems" umount -at ncpfs
+ fi
+ fi
+ fi
- for i in `find_ldap_interfaces` ; do
- /sbin/ifdown $i boot
+ for i in $tunnels; do
+ run_cmd -a "$(nls 'Shutting down tunnel interface') $i" /sbin/ifdown tnlcfg-$i boot
+ run_cmd -a "$(nls 'Removing tunnel') $i" /sbin/tnldown $i boot
done
for i in $interfaces_sit_boot $interfaces_boot ; do
- /sbin/ifdown $i boot
+ run_cmd -a "$(nls 'Shutting down interface') $i" /sbin/ifdown $i boot
done
network_deinit
echo "lo $interfaces"
nls "Configured tunnels:"
echo "$tunnels"
-
+ echo
+ nls "Currently inactive devices and tunnels:"
+ /sbin/ip link show | awk -F":" '(/^[0-90-90-9]:/) && ! (/UP/) { print $2 }' | xargs
nls "Currently active devices and tunnels:"
/sbin/ip link show | awk -F":" ' (/UP/) { print $2 }' | xargs
;;