3 # manage network interfaces and configure some networking options
5 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
7 if ! [ -x /sbin/ifup ]; then
11 spoofprotect_rp_filter () {
12 # This is the best method: turn on Source Address Verification and get
13 # spoof protection on all current and future interfaces.
15 if [ -e /proc/sys/net/ipv4/conf/all/rp_filter ]; then
16 for f in /proc/sys/net/ipv4/conf/*; do
17 [ -e $f/rp_filter ] && echo 1 > $f/rp_filter
26 echo -n "Setting up IP spoofing protection: "
27 if spoofprotect_rp_filter; then
35 if [ -e /proc/sys/net/ipv4/ip_forward ]; then
36 echo -n "Enabling packet forwarding... "
37 echo 1 > /proc/sys/net/ipv4/ip_forward
43 if [ -e /proc/sys/net/ipv4/tcp_syncookies ]; then
44 echo -n "Enabling TCP/IP SYN cookies... "
45 echo 1 > /proc/sys/net/ipv4/tcp_syncookies
50 wpa_supplicantcheck () {
51 if [ -e /var/run/wpa_supplicant ]; then
52 echo -n "disabling wpa_supplicant "
53 start-stop-daemon -K -x /usr/sbin/wpa_supplicant
54 # HACK: wpa_supplicant sometimes doesn't quit properly on SIGTERM.
55 if [ -e /var/run/wpa_supplicant ]; then
56 echo -n "wpa_supplicant still running, force kill now.. "
57 killall -9 /usr/sbin/wpa_supplicant
58 rm -rf /var/run/wpa_supplicant
68 opt=`grep "^$optname=" /etc/network/options`
69 if [ -z "$opt" ]; then
70 opt="$optname=$default"
72 optval=${opt#$optname=}
73 if [ "$optval" = "yes" ]; then
80 doopt spoofprotect yes
84 echo -n "Configuring network interfaces... "
90 if sed -n 's/^[^ ]* \([^ ]*\) \([^ ]*\) .*$/\1 \2/p' /proc/mounts |
91 grep -q "^/ nfs$"; then
92 echo "NOT deconfiguring network interfaces: / is an NFS mount"
93 elif sed -n 's/^[^ ]* \([^ ]*\) \([^ ]*\) .*$/\1 \2/p' /proc/mounts |
94 grep -q "^/ smbfs$"; then
95 echo "NOT deconfiguring network interfaces: / is an SMB mount"
96 elif sed -n 's/^[^ ]* \([^ ]*\) \([^ ]*\) .*$/\2/p' /proc/mounts |
97 grep -qE '^(nfs|smbfs|ncp|coda)$'; then
98 echo "NOT deconfiguring network interfaces: network shares still mounted."
100 echo -n "Deconfiguring network interfaces... "
106 force-reload|restart)
107 echo -n "Reconfiguring network interfaces... "
114 echo "Usage: /etc/init.d/networking {start|stop|restart|force-reload}"