1 # $OpenBSD: faq-example2,v 1.3 2005/07/02 16:16:39 joel Exp $
2 # $DragonFly: src/share/examples/pf/faq-example2,v 1.1 2005/12/13 01:58:27 corecode Exp $
6 # http://www.openbsd.org/faq/pf/queueing.html#example1
10 # enable queueing on the external interface to control traffic going to
11 # the Internet. use the priq scheduler to control only priorities. set
12 # the bandwidth to 610Kbps to get the best performance out of the TCP
15 altq on fxp0 priq bandwidth 610Kb queue { std_out, ssh_im_out, dns_out, \
18 # define the parameters for the child queues.
19 # std_out - the standard queue. any filter rule below that does not
20 # explicitly specify a queue will have its traffic added
22 # ssh_im_out - interactive SSH and various instant message traffic.
23 # dns_out - DNS queries.
24 # tcp_ack_out - TCP ACK packets with no data payload.
26 queue std_out priq(default)
27 queue ssh_im_out priority 4 priq(red)
28 queue dns_out priority 5
29 queue tcp_ack_out priority 6
31 # enable queueing on the internal interface to control traffic coming in
32 # from the Internet. use the cbq scheduler to control bandwidth. max
35 altq on dc0 cbq bandwidth 2Mb queue { std_in, ssh_im_in, dns_in, bob_in }
37 # define the parameters for the child queues.
38 # std_in - the standard queue. any filter rule below that does not
39 # explicitly specify a queue will have its traffic added
41 # ssh_im_in - interactive SSH and various instant message traffic.
42 # dns_in - DNS replies.
43 # bob_in - bandwidth reserved for Bob's workstation. allow him to
46 queue std_in bandwidth 1.6Mb cbq(default)
47 queue ssh_im_in bandwidth 200Kb priority 4
48 queue dns_in bandwidth 120Kb priority 5
49 queue bob_in bandwidth 80Kb cbq(borrow)
52 # ... in the filtering section of pf.conf ...
56 charlie = "192.168.0.4"
57 local_net = "192.168.0.0/24"
58 ssh_ports = "{ 22 2022 }"
59 im_ports = "{ 1863 5190 5222 }"
61 # filter rules for fxp0 inbound
64 # filter rules for fxp0 outbound
66 pass out on fxp0 inet proto tcp from (fxp0) to any flags S/SA \
67 keep state queue(std_out, tcp_ack_out)
68 pass out on fxp0 inet proto { udp icmp } from (fxp0) to any keep state
69 pass out on fxp0 inet proto { tcp udp } from (fxp0) to any port domain \
70 keep state queue dns_out
71 pass out on fxp0 inet proto tcp from (fxp0) to any port $ssh_ports \
72 flags S/SA keep state queue(std_out, ssh_im_out)
73 pass out on fxp0 inet proto tcp from (fxp0) to any port $im_ports \
74 flags S/SA keep state queue(ssh_im_out, tcp_ack_out)
76 # filter rules for dc0 inbound
78 pass in on dc0 from $local_net
80 # filter rules for dc0 outbound
82 pass out on dc0 from any to $local_net
83 pass out on dc0 proto { tcp udp } from any port domain to $local_net \
85 pass out on dc0 proto tcp from any port $ssh_ports to $local_net \
86 queue(std_in, ssh_im_in)
87 pass out on dc0 proto tcp from any port $im_ports to $local_net \
89 pass out on dc0 from any to $bob queue bob_in