]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/init.d/network
- removed all "xargs" calls
[projects/rc-scripts.git] / rc.d / init.d / network
1 #!/bin/sh
2 #
3 # network       Bring up/down networking
4 #
5 # chkconfig:    2345 10 90
6 # description:  Activates/Deactivates all network interfaces configured to \
7 #               start at boot time.
8 #
9 # probe:        true
10
11 # $Id: network,v 1.35 2000/08/28 15:35:48 zagrodzki Exp $
12
13 # NLS
14 NLS_DOMAIN="rc-scripts"
15
16 # Source function library.
17 . /etc/rc.d/init.d/functions
18 . /etc/sysconfig/network-scripts/.functions
19
20 [ ! -f /etc/sysconfig/network ] && exit 0
21
22 . /etc/sysconfig/network
23
24 # Check that networking is up.
25 is_no "${NETWORKING}" && exit 0
26
27 [ -x /sbin/ip ] || exit 0
28
29 ######
30 # initialize networking:
31 # - check IPv4, IPv6, IPX can be handled by system
32 # - setup default IPv{4,6} interfaces policy like:
33 #   - forwarding,
34 #   - spoofig protection,
35 #   - icmp echo ignore broadcasts,
36 # - setup lo interface
37 network_init()
38 {
39 # Set UP loopback interface
40 set_up_loopback
41
42 # Modprobe needed devices
43 modprobe_net
44
45 # Spoofing protection && dynamic IP && port range
46 ipv4_anti_spoofing on
47 ipv4_dynamic_ip_patch on
48 ipv4_local_port_range on
49
50 # Others proc/sys/net
51 proc_networking start
52
53 # Setup NAT rules
54 setup_nat on
55 setup_routes on
56
57 # Setup IPX
58 if is_yes "$IPX"; then
59         if [ ! -z $IPXAUTOPRIMARY ] ; then
60                 /usr/bin/ipx_configure --auto_primary=$IPXAUTOPRIMARY
61         fi
62         if [ ! -z $IPXAUTOFRAME ] ; then
63                 /usr/bin/ipx_configure --auto_interface=$IPXAUTOFRAME
64         fi
65         if [ ! -z "$IPXINTERNALNETNUM" -a "$IPXINTERNALNETNUM" != "0" ]; then
66                 /usr/bin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM
67         fi
68 fi
69 }
70
71 network_postinit()
72 {
73 # Set static ARP table
74 static_arp
75
76 # Start rdisc daemon
77 rdisc on
78 }
79
80 ######
81 # deinitialize networking
82 # - down lo interface.
83 network_deinit()
84 {
85 setup_routes off
86
87 # Set down NAT rules
88 setup_nat off
89
90 # Shut down rdisc daemon
91 rdisc off
92
93 # Spoofing protection && dynamic IP && port range
94 ipv4_anti_spoofing off
95 ipv4_dynamic_ip_patch off
96 ipv4_local_port_range off
97
98 # Others proc/sys/net
99 proc_networking stop
100
101 # Set DOWN loopback interface
102 set_down_loopback
103 }
104
105 proc_networking()
106 {
107 TODO="$1"
108
109 # IPv4 forwarding
110 proc_net ipv4/ip_forward $TODO 1 0 IPV4_FORWARDING "IPv4 forwarding"
111 # IPv6 forwarding
112 if is_yes "$IPV6_NETWORKING"; then
113    proc_net ipv6/conf/all/forwarding $TODO 1 0 IPV6_FORWARDING "IPv6 forwarding"
114 fi
115 # Others proc/net
116 proc_net ipv4/conf/all/accept_redirects $TODO 1 0 IPV4_ACCEPT_ICMP_REDIR ""
117 proc_net ipv4/conf/all/accept_source_route $TODO 1 1 IPV4_ACCEPT_SOURCE_ROUTE ""
118 proc_net ipv4/conf/all/log_martians $TODO 1 0 IPV4_LOG_MARTIANS ""
119 proc_net ipv4/conf/all/mc_forwarding $TODO 1 0 IPV4_MULTICAST ""
120 proc_net ipv4/conf/all/proxy_arp $TODO 1 0 IPV4_PROXY_ARP ""
121 proc_net ipv4/conf/all/secure_redirects $TODO 1 1 IPV4_ACCEPT_ICMP_REDIR_GATE ""
122 proc_net ipv4/conf/all/send_redirects $TODO 1 1 IPV4_SEND_ICMP_REDIR ""
123 proc_net ipv4/icmp_echo_ignore_all $TODO 1 0 IPV4_IGN_ALL_ICMP ""
124 proc_net ipv4/icmp_echo_ignore_broadcasts $TODO 1 1 IPV4_IGN_CAST_ICMP ""
125 proc_net ipv4/ip_no_pmtu_disc $TODO 1 0 IPV4_MTU_DISCOVERY ""
126 proc_net ipv4/ip_masq_debug $TODO 1 0 IPV4_MASQ_DEBUGGING ""
127 proc_net ipv4/tcp_retrans_collapse $TODO 0 1 IPV4_RETRANS_COLLAPSE ""
128 proc_net ipv4/tcp_sack $TODO 0 1 IPV4_NO_SELECT_ACK ""
129 proc_net ipv4/tcp_timestamps $TODO 0 1 IPV4_NO_TIMESTAMPS ""
130 proc_net ipv4/tcp_stdurg $TODO 1 0 IPV4_RFC793 ""
131 proc_net ipv4/tcp_syncookies $TODO 1 0 IPV4_SYN_COOKIES ""
132 proc_net ipv4/tcp_window_scaling $TODO 1 0 IPV4_NO_WINDOW_SCALING ""
133 }
134
135 # find all the interfaces besides loopback.
136 # ignore aliases, alternative configurations, and editor backup files
137
138 interfaces="`(ls /etc/sysconfig/interfaces/ifcfg* | \
139 egrep -v '(ifcfg-lo|:)' | egrep 'ifcfg-[a-z0-9]+$' | \
140 sed 's!^/etc/sysconfig/interfaces/ifcfg-!!g') 2> /dev/null`"
141
142 interfaces_boot="`(alias xx="ls /etc/sysconfig/interfaces/ifcfg* |\
143 egrep -v '(ifcfg-lo|ifcfg-sit|:)' | egrep 'ifcfg-[a-z0-9]+$'" ; \
144 for i in \`xx\`; do ONBOOT=""; . $i; if is_yes "$ONBOOT"; then \
145 echo $i; fi; done | sed 's!^/etc/sysconfig/interfaces/ifcfg-!!g') 2> /dev/null`"
146
147 interfaces_sit_boot="`(alias xx="ls /etc/sysconfig/interfaces/ifcfg-sit* | \
148 egrep 'ifcfg-[a-z0-9]+$'"; for i in \`xx\`; do ONBOOT=""; . $i; \
149 if is_yes "$ONBOOT"; then echo $i; fi; done | \
150 sed 's!^/etc/sysconfig/interfaces/ifcfg-!!g') 2> /dev/null`"
151
152 tunnels="`(alias xx="ls /etc/sysconfig/interfaces/tnlcfg-*"; \
153 for i in \`xx\`; do ONBOOT=""; . $i; if is_yes "$ONBOOT"; then echo $i; \
154 fi; done | sed 's!^/etc/sysconfig/interfaces/tnlcfg-!!g') 2> /dev/null`"
155
156 # See how we were called.
157 case "$1" in
158   start)
159         network_init
160
161         for i in $interfaces_boot $interfaces_sit_boot ; do
162                 /sbin/ifup $i boot
163         done
164
165         for i in `find_ldap_interfaces` ; do
166                 /sbin/ifup $i boot
167         done
168
169         for i in $tunnels; do
170                 /sbin/tnlup $i boot
171                 /sbin/ifup tnlcfg-$i boot
172         done
173         
174         network_postinit
175
176         touch /var/lock/subsys/network
177         ;;
178   stop)
179         for i in $tunnels; do
180                 /sbin/ifdown tnlcfg-$i boot
181                 /sbin/tnldown $i boot
182         done
183
184         for i in `find_ldap_interfaces` ; do
185                 /sbin/ifdown $i boot
186         done
187
188         for i in $interfaces_sit_boot $interfaces_boot ; do
189                 /sbin/ifdown $i boot
190         done
191
192         network_deinit
193
194         rm -f /var/lock/subsys/network
195         ;;
196   status)
197         nls "Configured devices:"
198         echo "lo $interfaces"
199         nls "Configured tunnels:"
200         echo "$tunnels"
201
202         nls "Currently active devices and tunnels:"
203         /sbin/ip link show | egrep '^[^ ].*' | sed 's/[0-9]*: \(.*\):.*/\1/' | \
204                 tr '\n' ' '; echo
205         ;;
206   restart)
207         $0 stop
208         $0 start
209         ;;
210   *)
211         echo "Usage: $0 {start|stop|restart|status}"
212         exit 1
213 esac
214
215 exit 0
This page took 0.060764 seconds and 4 git commands to generate.