Changeset 10185 in hybrid for branches/releng-9.0/nanobsd/files/etc
- Timestamp:
- Mar 17, 2012, 11:51:28 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/releng-9.0/nanobsd/files/etc/ipfw.sh
r10136 r10185 1 # !/bin/sh -2 # Based on /etc/rc.firewall 3 # 4 # Credits: Richard van Mansom, Rick van der Zwet 1 ## Building options 2 dumpdev="NO" # No kernel dumps as we don't have a place to 3 # store them 4 ipv6_enable="NO" # No IPv6 support for now, near feature... ;-) 5 5 6 # NTP server needs working config with WL network or internet on boot 7 # so some warnings might pop up, but no harm 8 ntpdate_enable="YES" 9 ntpd_enable="YES" 10 ntpd_sync_on_start="YES" 11 ntpd_flags="-p /var/run/ntpd.pid -f /var/db/ntp.drift" 6 12 7 allowed2internet="80,443" 8 maxconnections="10"13 # We need no running mail server 14 sendmail_enable="NONE" 9 15 10 RFC1918_nets="10.0.0.0/8,172.16.0.0/12,192.168.0.0/16" 11 WLNET='172.16.0.0/12' 16 # Don't let syslog accept input from other remote hosts 17 syslogd_enable="YES" 18 syslogd_flags="-s -A -c" 12 19 13 # Suck in the configuration variables. 14 if [ -z "${source_rc_confs_defined}" ]; then 15 if [ -r /etc/defaults/rc.conf ]; then 16 . /etc/defaults/rc.conf 17 source_rc_confs 18 elif [ -r /etc/rc.conf ]; then 19 . /etc/rc.conf 20 fi 21 fi 20 # Remote login without DNS checking as it might not also be functionable 21 # -u0 prevent sshd from making DNS requests unless the authentication mechanism 22 # or configuration requires it. 23 sshd_enable="YES" 24 sshd_flags="-u0" 22 25 23 setup_loopback () { 24 ############ 25 # Only in rare cases do you want to change these rules 26 # 27 ${fwcmd} add 100 pass all from any to any via lo0 28 ${fwcmd} add 200 deny all from any to 127.0.0.0/8 29 ${fwcmd} add 300 deny ip from 127.0.0.0/8 to any 30 } 26 # Don't update the motd as it not writeable, the update_nanobsd_motd is a 27 # simple wrapper found at /usr/local/etc/rc.d supporting this featureg 28 update_motd="NO" 29 update_nanobsd_motd="YES" 31 30 32 ############ 33 # Set quiet mode if requested 34 # 35 case ${firewall_quiet} in 36 [Yy][Ee][Ss]) 37 fwcmd="/sbin/ipfw -q" 38 ;; 39 *) 40 fwcmd="/sbin/ipfw" 41 ;; 42 esac 31 # Monitoring deamons 32 nrpe2_enable="YES" 33 snmpd_enable="YES" 34 snmpd_flags="-a -LF w /var/log/snmpd.log" 43 35 44 ########### 45 # Set Internal/External Interface 46 # 47 driver=`echo ${internalif} | sed 's/[0-9]*//g'` 48 seq=`echo ${internalif} | sed 's/[a-zA-Z]*//g'` 36 # HTTP(S) proxy server 37 tinyproxy_enable="YES" 49 38 50 if [ ${seq} = 0 ]; then 51 seq=`expr ${seq} \+ 1` 52 else 53 seq=`expr ${seq} \- 1` 54 fi 39 # Make sure generated ssh keys are saved 40 nanobsd_save_sshkeys_enable="YES" 55 41 56 externalif="$driver$seq" 42 ## Port extentions 43 # Serve our clients some pretty cool IP address to at least get connected 44 # Also some low-memory footprint dns resolver 45 dnsmasq_enable="YES" 57 46 58 # Get interface Addresses 59 externalip=`ifconfig $externalif | awk '/inet/ { print $2 }'` 60 internalip=`ifconfig $internalif | awk '/inet/ { print $2 }'` 61 ############ 62 # Flush out the list before we begin. 63 # 64 ${fwcmd} -f flush 47 ## WL ports extentions 48 thttpd_enable="YES" 49 http302_enable="YES" 65 50 66 setup_loopback 51 # Make sure generated ssh keys are saved 52 nanobsd_save_sshkeys_enable="YES" 67 53 68 69 ############ 70 # Block the hosters network (and maybe others) 71 for IP in ${firewall_block} 72 do 73 ${fwcmd} add deny ip from any to ${IP} in via $internalif 74 done 75 76 ############ 77 # Statefull filewall in use 78 ${fwcmd} add check-state 79 80 # Allow anything originating from me 81 ${fwcmd} add allow ip from me to any keep-state 82 83 84 ############# 85 # Outbound NAT setup 86 # WL Net -> Internet 87 ${fwcmd} add nat 100 all from $WLNET to any out recv $internalif xmit $externalif 88 ${fwcmd} add nat 100 all from any to $externalip in recv $externalif 89 ${fwcmd} nat 100 config if $externalif 90 91 # Subnet Internet is allowed 92 ${fwcmd} add allow tcp from $WLNET to any $allowed2internet in via $internalif setup limit src-addr $maxconnections 93 94 95 ############# 96 # Internal Network -> WL Net 97 # Inbound NAT setup, to allow proxy device to be used gateway from Internal Network to WL 98 ${fwcmd} add nat 200 all from $RFC1918_nets to $WLNET out recv $externalif xmit $internalif 99 ${fwcmd} add nat 200 all from $WLNET to $internalip in recv $internalif 100 ${fwcmd} nat 200 config if $internalif 101 102 # Allow all traffic inbound 103 ${fwcmd} add allow all from $RFC1918_nets to $WLNET in recv $externalif keep-state 104 105 106 ############# 107 ## Services in use 108 ## Allow on external interface 109 external_allow_tcp="ssh" 110 ${fwcmd} add allow tcp from any to me $external_allow_tcp via $externalif setup keep-state 111 112 ## Allow on internal interface 113 internal_allow_tcp="ssh,domain,3128" 114 internal_allow_udp="ntp,domain,snmp,12345" 115 ${fwcmd} add allow udp from $WLNET to me ${internal_allow_udp} via $internalif keep-state 116 ${fwcmd} add allow tcp from $WLNET to me ${internal_allow_tcp} via $internalif setup keep-state 117 118 # Basic ICMP managment traffic 119 ${fwcmd} add allow icmp from any to me icmptype 8 120 ${fwcmd} add allow icmp from me to any icmptype 3,4,11 121 122 123 ############# 124 # Block anything else 125 ${fwcmd} add 65000 deny log logamount 500 ip from any to any 126 54 #Hybrid 55 openvpn_enable="YES" 56 openvpn_if="tap" 57 cloned_interfaces="bridge0" 58 gateway_enable="YES" 59 pf_enable="YES" 60 pf_rules="/etc/pf.conf.ileiden" 61 pf_flags="" 62 pf2_enable="YES"
Note:
See TracChangeset
for help on using the changeset viewer.