Changeset 10136 in hybrid for trunk/nanobsd/files/etc/ipfw.sh


Ignore:
Timestamp:
Mar 12, 2012, 6:32:43 AM (13 years ago)
Author:
richardvm
Message:

domme toevoeging van proxy files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/nanobsd/files/etc/ipfw.sh

    r10135 r10136  
    11#!/bin/sh -
     2# Based on /etc/rc.firewall
     3#
     4# Credits: Richard van Mansom, Rick van der Zwet
    25
    3 # Based on /etc/rc.firewall
     6
     7allowed2internet="80,443"
     8maxconnections="10"
     9
     10RFC1918_nets="10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
     11WLNET='172.16.0.0/12'
    412
    513# Suck in the configuration variables.
     
    3442esac
    3543
     44###########
     45# Set Internal/External Interface
     46#
     47driver=`echo ${internalif} | sed 's/[0-9]*//g'`
     48seq=`echo ${internalif} | sed 's/[a-zA-Z]*//g'`
     49
     50if [ ${seq} = 0 ]; then
     51  seq=`expr ${seq} \+ 1`
     52else
     53  seq=`expr ${seq} \- 1`
     54fi
     55
     56externalif="$driver$seq"
     57
     58# Get interface Addresses
     59externalip=`ifconfig $externalif | awk '/inet/ { print $2 }'`
     60internalip=`ifconfig $internalif | awk '/inet/ { print $2 }'`
    3661############
    3762# Flush out the list before we begin.
     
    4166setup_loopback
    4267
    43 ############
    44 
    45 # By default no firewalling
    46 ${fwcmd} add 65000 pass all from any to any
    47 
    48 # Transproxy/WLportal/Captive portal
    49 ${fwcmd} add 10000 allow tcp from any to localhost 80
    50 ${fwcmd} add 10001 allow tcp from any to me 80
    5168
    5269############
    53 # Reserved: Whitelist rule numbers
    54 # 10002 - 10009
    55 NR=10002
    56   for IP in $captive_portal_whitelist; do
    57   ${fwcmd} add $NR allow tcp from $IP to not 172.16.0.0/12 dst-port 80
    58   NR=`expr $NR + 1`
     70# Block the hosters network (and maybe others)
     71for IP in ${firewall_block}
     72do
     73  ${fwcmd} add deny ip from any to ${IP} in via $internalif
    5974done
    6075
    6176############
    62 # Reserved: WLPortal rule numbers
    63 # 10010 - 10099
     77# Statefull filewall in use
     78${fwcmd} add check-state
    6479
    65 # Forward rules work without a base address, so needed a loop over all inet4 adresses
    66 for INF in $captive_portal_interfaces; do
    67   ${fwcmd} add 10100 fwd 172.31.255.1,8081 tcp from any to not 172.16.0.0/12 80 in via ${INF}
    68 done
     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
     109external_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
     113internal_allow_tcp="ssh,domain,3128"
     114internal_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
Note: See TracChangeset for help on using the changeset viewer.