]>
Commit | Line | Data |
---|---|---|
12de71be | 1 | #!/bin/sh |
7742e157 | 2 | # |
8d86e6df | 3 | # network Bring up/down networking |
7742e157 | 4 | # |
458f14b7 AM |
5 | # chkconfig: 2345 10 90 |
6 | # description: Activates/Deactivates all network interfaces configured to \ | |
8d86e6df | 7 | # start at boot time. |
458f14b7 | 8 | # |
8d86e6df | 9 | # probe: true |
7742e157 | 10 | |
8192b17e | 11 | # $Id: network,v 1.40 2000/11/16 15:58:54 baggins Exp $ |
38198f50 AM |
12 | |
13 | # NLS | |
14 | NLS_DOMAIN="rc-scripts" | |
15 | ||
7742e157 AF |
16 | # Source function library. |
17 | . /etc/rc.d/init.d/functions | |
ba26464c | 18 | . /etc/sysconfig/network-scripts/.functions |
7742e157 | 19 | |
7e04fe0e | 20 | [ ! -f /etc/sysconfig/network ] && exit 0 |
7742e157 AF |
21 | |
22 | . /etc/sysconfig/network | |
23 | ||
7742e157 | 24 | # Check that networking is up. |
dd4a755f | 25 | is_no "${NETWORKING}" && exit 0 |
7742e157 | 26 | |
4ac87c24 | 27 | [ -x /sbin/ip ] || exit 0 |
7742e157 | 28 | |
7e04fe0e | 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() | |
7742e157 | 38 | { |
38198f50 AM |
39 | # Set UP loopback interface |
40 | set_up_loopback | |
41 | ||
42 | # Modprobe needed devices | |
e016cdae AM |
43 | modprobe_net |
44 | ||
d4e799ff | 45 | # Spoofing protection && dynamic IP && port range |
e016cdae | 46 | ipv4_anti_spoofing on |
d4e799ff AM |
47 | ipv4_dynamic_ip_patch on |
48 | ipv4_local_port_range on | |
e016cdae | 49 | |
d4e799ff AM |
50 | # Others proc/sys/net |
51 | proc_networking start | |
38198f50 | 52 | |
833bc9cf AM |
53 | # Setup NAT rules |
54 | setup_nat on | |
47dbf68e | 55 | setup_routes on |
03f9cfee JR |
56 | |
57 | # Setup IPX | |
dd4a755f | 58 | if is_yes "$IPX"; then |
03f9cfee | 59 | if [ ! -z $IPXAUTOPRIMARY ] ; then |
dd4a755f | 60 | /usr/bin/ipx_configure --auto_primary=$IPXAUTOPRIMARY |
03f9cfee JR |
61 | fi |
62 | if [ ! -z $IPXAUTOFRAME ] ; then | |
dd4a755f | 63 | /usr/bin/ipx_configure --auto_interface=$IPXAUTOFRAME |
03f9cfee JR |
64 | fi |
65 | if [ ! -z "$IPXINTERNALNETNUM" -a "$IPXINTERNALNETNUM" != "0" ]; then | |
dd4a755f | 66 | /usr/bin/ipx_internal_net add $IPXINTERNALNETNUM $IPXINTERNALNODENUM |
03f9cfee | 67 | fi |
dd4a755f | 68 | fi |
7742e157 AF |
69 | } |
70 | ||
21c12948 AF |
71 | network_postinit() |
72 | { | |
73 | # Set static ARP table | |
74 | static_arp | |
75 | ||
fe648758 AM |
76 | # Start rdisc daemon |
77 | rdisc on | |
21c12948 AF |
78 | } |
79 | ||
7e04fe0e | 80 | ###### |
81 | # deinitialize networking | |
82 | # - down lo interface. | |
83 | network_deinit() | |
84 | { | |
47dbf68e | 85 | setup_routes off |
fe648758 | 86 | |
833bc9cf AM |
87 | # Set down NAT rules |
88 | setup_nat off | |
e016cdae | 89 | |
fe648758 AM |
90 | # Shut down rdisc daemon |
91 | rdisc off | |
92 | ||
d4e799ff | 93 | # Spoofing protection && dynamic IP && port range |
e016cdae | 94 | ipv4_anti_spoofing off |
d4e799ff AM |
95 | ipv4_dynamic_ip_patch off |
96 | ipv4_local_port_range off | |
97 | ||
98 | # Others proc/sys/net | |
99 | proc_networking stop | |
e016cdae | 100 | |
38198f50 AM |
101 | # Set DOWN loopback interface |
102 | set_down_loopback | |
7742e157 AF |
103 | } |
104 | ||
d4e799ff AM |
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 | |
dd4a755f | 112 | if is_yes "$IPV6_NETWORKING"; then |
6913d6ec AM |
113 | proc_net ipv6/conf/all/forwarding $TODO 1 0 IPV6_FORWARDING "IPv6 forwarding" |
114 | fi | |
d4e799ff AM |
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 "" | |
cfa9c900 JR |
133 | # ... and proc/net/ipv6 goodies |
134 | proc_net ipv6/conf/default/autoconf $TODO 0 1 IPV6_AUTOCONF "" | |
135 | proc_net ipv6/conf/default/autoconf_route $TODO 0 1 IPV6_AUTOCONF_ROUTE "" | |
d4e799ff AM |
136 | } |
137 | ||
5726f160 AM |
138 | # find all the interfaces besides loopback. |
139 | # ignore aliases, alternative configurations, and editor backup files | |
1e91649a | 140 | |
8b51cc24 JR |
141 | interfaces=$((cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \ |
142 | egrep -v '(ifcfg-lo|:)' | egrep 'ifcfg-[a-z0-9]+$' | \ | |
143 | awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null) | |
144 | interfaces_boot=$((cd /etc/sysconfig/interfaces && ls -1 ifcfg* | \ | |
145 | egrep -v '(ifcfg-lo|ifcfg-sit|ifcfg-atm|ifcfg-lec|:)' | egrep 'ifcfg-[a-z0-9]+$' | \ | |
146 | xargs egrep -l "ONBOOT=[^n][^o]" | \ | |
147 | awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null) | |
148 | interfaces_sit_boot=$((cd /etc/sysconfig/interfaces && ls -1 ifcfg-sit* | \ | |
149 | egrep 'ifcfg-[a-z0-9]+$' | xargs egrep -l "ONBOOT=[^n][^o]" | \ | |
150 | awk ' { gsub(/ifcfg-/,NIL); print $0 } ') 2> /dev/null) | |
151 | tunnels=$((cd /etc/sysconfig/interfaces && ls -1 tnlcfg-* | \ | |
152 | xargs egrep -l "ONBOOT=[^n][^o]" | \ | |
153 | awk ' { gsub(/tnlcfg-/,NIL); print $0 } ') 2> /dev/null) | |
12de71be | 154 | |
7742e157 AF |
155 | # See how we were called. |
156 | case "$1" in | |
157 | start) | |
7e04fe0e | 158 | network_init |
d4e799ff | 159 | |
97e54bef JK |
160 | for i in $interfaces_boot $interfaces_sit_boot ; do |
161 | /sbin/ifup $i boot | |
162 | done | |
163 | ||
164 | for i in `find_ldap_interfaces` ; do | |
833bc9cf | 165 | /sbin/ifup $i boot |
4ac87c24 AM |
166 | done |
167 | ||
833bc9cf AM |
168 | for i in $tunnels; do |
169 | /sbin/tnlup $i boot | |
170 | /sbin/ifup tnlcfg-$i boot | |
7742e157 | 171 | done |
21c12948 AF |
172 | |
173 | network_postinit | |
4ac87c24 | 174 | |
7742e157 AF |
175 | touch /var/lock/subsys/network |
176 | ;; | |
177 | stop) | |
833bc9cf AM |
178 | for i in $tunnels; do |
179 | /sbin/ifdown tnlcfg-$i boot | |
180 | /sbin/tnldown $i boot | |
7742e157 | 181 | done |
4ac87c24 | 182 | |
97e54bef JK |
183 | for i in `find_ldap_interfaces` ; do |
184 | /sbin/ifdown $i boot | |
185 | done | |
186 | ||
187 | for i in $interfaces_sit_boot $interfaces_boot ; do | |
833bc9cf AM |
188 | /sbin/ifdown $i boot |
189 | done | |
4ac87c24 | 190 | |
7e04fe0e | 191 | network_deinit |
d4e799ff | 192 | |
7742e157 AF |
193 | rm -f /var/lock/subsys/network |
194 | ;; | |
195 | status) | |
38198f50 | 196 | nls "Configured devices:" |
4ac87c24 | 197 | echo "lo $interfaces" |
38198f50 | 198 | nls "Configured tunnels:" |
4ac87c24 AM |
199 | echo "$tunnels" |
200 | ||
60df57e7 | 201 | nls "Currently active devices and tunnels:" |
8192b17e | 202 | /sbin/ip link show | awk -F":" ' (/UP/) { print $2 }' | xargs |
7742e157 AF |
203 | ;; |
204 | restart) | |
205 | $0 stop | |
206 | $0 start | |
207 | ;; | |
7742e157 | 208 | *) |
38198f50 | 209 | echo "Usage: $0 {start|stop|restart|status}" |
7742e157 AF |
210 | exit 1 |
211 | esac | |
212 | ||
213 | exit 0 | |
8192b17e JR |
214 | |
215 | # This must be last line ! | |
216 | # vi:syntax=sh:tw=78:ts=8:sw=4 |