diff options
Diffstat (limited to 'share')
-rw-r--r-- | share/pf/Makefile | 4 | ||||
-rw-r--r-- | share/pf/faq-example1 | 46 | ||||
-rw-r--r-- | share/pf/faq-example2 | 87 | ||||
-rw-r--r-- | share/pf/faq-example3 | 117 |
4 files changed, 252 insertions, 2 deletions
diff --git a/share/pf/Makefile b/share/pf/Makefile index 14694fa56f8..a989eb13f65 100644 --- a/share/pf/Makefile +++ b/share/pf/Makefile @@ -1,7 +1,7 @@ # -# $OpenBSD: Makefile,v 1.4 2003/03/02 12:19:57 dhartmei Exp $ +# $OpenBSD: Makefile,v 1.5 2003/08/02 18:25:49 henning Exp $ # -FILES= queue1 queue2 queue3 ackpri +FILES= queue1 queue2 queue3 ackpri faq-example1 faq-example2 faq-example3 NOOBJ= noobj all clean cleandir depend lint tags: diff --git a/share/pf/faq-example1 b/share/pf/faq-example1 new file mode 100644 index 00000000000..8e50f998278 --- /dev/null +++ b/share/pf/faq-example1 @@ -0,0 +1,46 @@ +# $OpenBSD: faq-example1,v 1.1 2003/08/02 18:25:49 henning Exp $ + +# +# Firewall for Home or Small Office +# + + +# macros +int_if = "fxp0" +ext_if = "ep0" + +tcp_services = "{ 22, 113 }" +icmp_types = "echoreq" + +priv_nets = "{ 127.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8 }" + +# options +set block-policy return +set loginterface $ext_if + +# scrub +scrub in all + +# nat/rdr +nat on $ext_if from $int_if:network to any -> ($ext_if) +rdr on $int_if proto tcp from any to any port 21 -> 127.0.0.1 \ + port 8021 + +# filter rules +block all + +pass quick on lo0 all + +block drop in quick on $ext_if from $priv_nets to any +block drop out quick on $ext_if from any to $priv_nets + +pass in on $ext_if inet proto tcp from any to ($ext_if) \ + port $tcp_services flags S/SA keep state + +pass in inet proto icmp all icmp-type $icmp_types keep state + +pass in on $int_if from $int_if:network to any keep state +pass out on $int_if from any to $int_if:network keep state + +pass out on $ext_if proto tcp all modulate state flags S/SA +pass out on $ext_if proto { udp, icmp } all keep state diff --git a/share/pf/faq-example2 b/share/pf/faq-example2 new file mode 100644 index 00000000000..dc6737ca92c --- /dev/null +++ b/share/pf/faq-example2 @@ -0,0 +1,87 @@ +# $OpenBSD: faq-example2,v 1.1 2003/08/02 18:25:49 henning Exp $ + +# +# Small, Home Network +# + + +# enable queueing on the external interface to control traffic going to +# the Internet. use the priq scheduler to control only priorities. set +# the bandwidth to 610Kbps to get the best performance out of the TCP +# ACK queue. + +altq on fxp0 priq bandwidth 610Kb queue { std_out, ssh_im_out, dns_out, \ + tcp_ack_out } + +# define the parameters for the child queues. +# std_out - the standard queue. any filter rule below that does not +# explicitly specify a queue will have its traffic added +# to this queue. +# ssh_im_out - interactive SSH and various instant message traffic. +# dns_out - DNS queries. +# tcp_ack_out - TCP ACK packets with no data payload. + +queue std_out priq(default) +queue ssh_im_out priority 4 priq(red) +queue dns_out priority 5 +queue tcp_ack_out priority 6 + +# enable queueing on the internal interface to control traffic coming in +# from the Internet. use the cbq scheduler to control bandwidth. max +# bandwidth is 2Mbps. + +altq on dc0 cbq bandwidth 2Mb queue { std_in, ssh_im_in, dns_in, bob_in } + +# define the parameters for the child queues. +# std_in - the standard queue. any filter rule below that does not +# explicitly specify a queue will have its traffic added +# to this queue. +# ssh_im_in - interactive SSH and various instant message traffic. +# dns_in - DNS replies. +# bob_in - bandwidth reserved for Bob's workstation. allow him to +# borrow. + +queue std_in cbq(default) +queue ssh_im_in priority 4 +queue dns_in priority 5 +queue bob_in bandwidth 80Kb cbq(borrow) + + +# ... in the filtering section of pf.conf ... + +alice = "192.168.0.2" +bob = "192.168.0.3" +charlie = "192.168.0.4" +local_net = "192.168.0.0/24" +ssh_ports = "{ 22 2022 }" +im_ports = "{ 1863 5190 5222 }" + +# filter rules for fxp0 inbound +block in on fxp0 all + +# filter rules for fxp0 outbound +block out on fxp0 all +pass out on fxp0 inet proto tcp from (fxp0) to any flags S/SA \ + keep state queue(std_out, tcp_ack_out) +pass out on fxp0 inet proto { udp icmp } from (fxp0) to any keep state +pass out on fxp0 inet proto { tcp udp } from (fxp0) to any port domain \ + keep state queue dns_out +pass out on fxp0 inet proto tcp from (fxp0) to any port $ssh_ports \ + flags S/SA keep state queue(std_out, ssh_im_out) +pass out on fxp0 inet proto tcp from (fxp0) to any port $im_ports \ + flags S/SA keep state queue(ssh_im_out, tcp_ack_out) + +# filter rules for dc0 inbound +block in on dc0 all +pass in on dc0 from $local_net + +# filter rules for dc0 outbound +block out on dc0 all +pass out on dc0 from any to $local_net +pass out on dc0 proto { tcp udp } from any port domain to $local_net \ + queue dns_in +pass out on dc0 proto tcp from any port $ssh_ports to $local_net \ + queue(std_in, ssh_im_in) +pass out on dc0 proto tcp from any port $im_ports to $local_net \ + queue ssh_im_in +pass out on dc0 from any to $bob queue bob_in diff --git a/share/pf/faq-example3 b/share/pf/faq-example3 new file mode 100644 index 00000000000..696475385f2 --- /dev/null +++ b/share/pf/faq-example3 @@ -0,0 +1,117 @@ +# $OpenBSD: faq-example3,v 1.1 2003/08/02 18:25:49 henning Exp $ + +# +# Company Network +# + + +# enable queueing on the external interface to queue packets going out +# to the Internet. use the cbq scheduler so that the bandwidth use of +# each queue can be controlled. the max outgoing bandwidth is 1.5Mbps. + +altq on fxp0 cbq bandwidth 1.5Mb queue { std_ext, www_ext, boss_ext } + +# define the parameters for the child queues. +# std_ext - the standard queue. also the default queue for +# outgoing traffic on fxp0. +# www_ext - container queue for WWW server queues. limit to +# 500Kbps. +# www_ext_http - http traffic from the WWW server +# www_ext_misc - all non-http traffic from the WWW server +# boss_ext - traffic coming from the boss's computer + +queue std_ext cbq(default) +queue www_ext bandwidth 500Kb { www_ext_http, www_ext_misc } + queue www_ext_http priority 3 cbq(red) + queue www_ext_misc priority 1 +queue boss_ext priority 3 + +# enable queueing on the internal interface to control traffic coming +# from the Internet or the DMZ. use the cbq scheduler to control the +# bandwidth of each queue. bandwidth on this interface is set to the +# maximum. traffic coming from the DMZ will be able to use all of this +# bandwidth while traffic coming from the Internet will be limited to +# 1.0Mbps (because 0.5Mbps (500Kbps) is being allocated to fxp1). + +altq on dc0 cbq bandwidth 100% queue { net_int, www_int } + +# define the parameters for the child queues. +# net_int - container queue for traffic from the Internet. bandwidth +# is 1.0Mbps. +# std_int - the standard queue. also the default queue for outgoing +# traffic on dc0. +# it_int - traffic to the IT Dept network. +# boss_int - traffic to the boss's PC. +# www_int - traffic from the WWW server in the DMZ. + +queue net_int bandwidth 1.0Mb { std_int, it_int, boss_int } + queue std_int cbq(default) + queue it_int bandwidth 500Kb cbq(borrow) + queue boss_int priority 3 +queue www_int cbq(red) + +# enable queueing on the DMZ interface to control traffic destined for +# the WWW server. cbq will be used on this interface since detailed +# control of bandwidth is necessary. bandwidth on this interface is set +# to the maximum. traffic from the internal network will be able to use +# all of this bandwidth while traffic from the Internet will be limited +# to 500Kbps. + +altq on fxp1 cbq bandwidth 100% queue { internal_dmz, net_dmz } + +# define the parameters for the child queues. +# internal_dmz - traffic from the internal network. +# net_dmz - container queue for traffic from the Internet. +# net_dmz_http - http traffic. +# net_dmz_misc - all non-http traffic. this is also the default queue. + +queue internal_dmz # no special settings needed +queue net_dmz bandwidth 500Kb { net_dmz_http, net_dmz_misc } + queue net_dmz_http priority 3 cbq(red) + queue net_dmz_misc priority 1 cbq(default) + + +# ... in the filtering section of pf.conf ... + +main_net = "192.168.0.0/24" +it_net = "192.168.1.0/24" +int_nets = "{ 192.168.0.0/24, 192.168.1.0/24 }" +dmz_net = "10.0.0.0/24" + +boss = "192.168.0.200" +wwwserv = "10.0.0.100" + +# default deny +block on { fxp0, fxp1, dc0 } all + +# filter rules for fxp0 inbound +pass in on fxp0 proto tcp from any to $wwwserv port { 21, \ + > 49151 } flags S/SA keep state queue www_ext_misc +pass in on fxp0 proto tcp from any to $wwwserv port 80 \ + flags S/SA keep state queue www_ext_http + +# filter rules for fxp0 outbound +pass out on fxp0 from $int_nets to any keep state +pass out on fxp0 from $boss to any keep state queue boss_ext + +# filter rules for dc0 inbound +pass in on dc0 from $int_nets to any keep state +pass in on dc0 from $it_net to any queue it_int +pass in on dc0 from $boss to any queue boss_int +pass in on dc0 proto tcp from $int_nets to $wwwserv port { 21, 80, \ + > 49151 } flags S/SA keep state queue www_int + +# filter rules for dc0 outbound +pass out on dc0 from dc0 to $int_nets + +# filter rules for fxp1 inbound +pass in on fxp1 proto { tcp, udp } from $wwwserv to any port 53 \ + keep state + +# filter rules for fxp1 outbound +pass out on fxp1 proto tcp from any to $wwwserv port { 21, \ + > 49151 } flags S/SA keep state queue net_dmz_misc +pass out on fxp1 proto tcp from any to $wwwserv port 80 \ + flags S/SA keep state queue net_dmz_http +pass out on fxp1 proto tcp from $int_nets to $wwwserv port { 80, \ + 21, > 49151 } flags S/SA keep state queue internal_dmz |