1 #!/bin/sh 2 # 3 # $NetBSD: ipfilter,v 1.10.4.1 2004/09/21 15:14:20 tron Exp $ 4 # 5 6 # PROVIDE: ipfilter 7 # REQUIRE: root beforenetlkm mountcritlocal tty 8 9 . /etc/rc.subr 10 11 name="ipfilter" 12 rcvar=$name 13 start_precmd="ipfilter_prestart" 14 start_cmd="ipfilter_start" 15 stop_precmd="test -f /etc/ipf.conf -o -f /etc/ipf6.conf" 16 stop_cmd="ipfilter_stop" 17 reload_precmd="$stop_precmd" 18 reload_cmd="ipfilter_reload" 19 resync_precmd="$stop_precmd" 20 resync_cmd="ipfilter_resync" 21 status_precmd="$stop_precmd" 22 status_cmd="ipfilter_status" 23 extra_commands="reload resync status" 24 25 ipfilter_prestart() 26 { 27 if [ ! -f /etc/ipf.conf ] && [ ! -f /etc/ipf6.conf ]; then 28 warn "/etc/ipf*.conf not readable; ipfilter start aborted." 29 # 30 # If booting directly to multiuser, send SIGTERM to 31 # the parent (/etc/rc) to abort the boot 32 # 33 if [ "$autoboot" = yes ]; then 34 echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!" 35 kill -TERM $$ 36 exit 1 37 fi 38 return 1 39 fi 40 return 0 41 } 42 43 ipfilter_start() 44 { 45 echo "Enabling ipfilter." 46 /sbin/ipf -E -Fa 47 if [ -f /etc/ipf.conf ]; then 48 /sbin/ipf -Fa -f /etc/ipf.conf 49 fi 50 if [ -f /etc/ipf6.conf ]; then 51 /sbin/ipf -6 -Fa -f /etc/ipf6.conf 52 fi 53 } 54 55 ipfilter_stop() 56 { 57 echo "Disabling ipfilter." 58 /sbin/ipf -D 59 } 60 61 ipfilter_reload() 62 { 63 echo "Reloading ipfilter rules." 64 65 if [ -f /etc/ipf.conf ] && ! /sbin/ipf -I -Fa -f /etc/ipf.conf; then 66 err 1 "reload of ipf.conf failed; not swapping to new ruleset." 67 fi 68 if [ -f /etc/ipf6.conf ] && ! /sbin/ipf -6 -I -Fa -f /etc/ipf6.conf; then 69 err 1 "reload of ipf6.conf failed; not swapping to new ruleset." 70 fi 71 /sbin/ipf -s 72 } 73 74 ipfilter_resync() 75 { 76 /sbin/ipf -y 77 } 78 79 ipfilter_status() 80 { 81 /sbin/ipf -V 82 } 83 84 load_rc_config $name 85 run_rc_command "$1" 86