Pf Queuing - ChiBUG · PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (2024)

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (1)

PF QUEUINGFOR OPENBSD 5.5 AND NEWER

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (2)

HISTORY

• ALTQ ( included 3.0 – 5.5)

• Natively Off

• Required a daemon (3.0 – 3.4)

• 3 Schedulers

• Class Based

• Priority

• HFSC

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (3)

NEW QUEUING SYSTEM

• New Syntax ( Easier in my opinion )

• Always On

• Priority’s are set via rules

• HFSC Scheduler[1]

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (4)

FUNCTIONALITY

• Only shapes outbound traffic on the ifspec interface *

• Only shapes traffic when no bandwidth available *

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (5)

BENEFITS

• Prevent timeouts from an overloaded outbound connection

• Maintain purchased speed on an unmetered drop (billed by hourly average)

• Prioritize Voice and Video applications and prevents jitter

• Insure small file transfers and page load times are faster than larger file

transfers

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (6)

MINIMUM REQUIREMENTS

• At least 1 queue specified in pf.conf to function

queue root on em0 bandwidth 100M default

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (7)

USAGE SCENARIOS

• Web Server

• Home or Office Firewall

• Router

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (8)

WEB SERVER

queue root on em0 bandwidth 100M max 100M

queue http parent root bandwidth 30M max 30M burst 80M for 3000ms

queue ssh parent root bandwidth 10M

queue ssh_int parent ssh bandwidth 5M

queue ssh_bulk parent ssh bandwidth 5M

pass in on em0 proto tcp to port {80,443} set queue http

pass in on em0 proto tcp to port ssh set queue (ssh_bulk, ssh_int)

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (9)

HOME FIREWALL

queue root em0 bandwidth 10M max 10M burst 12500K for 6400ms

queue dns parent root bandwidth 500K

queue ack parent root bandwidth 4M

queue bulk parent root bandwidth 5500K default

match on em0 proto tcp to port {21,80,443,5223} set queue (bulk,ack) set prio (3, 6)

match out on em0 proto udp set prio 4

match out on em0 proto {tcp,udp} from any to any port 53 set queue dns set prio 7

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (10)

ROUTER

queue l3 on em0 bandwidth 500M max 500M default

queue ntt on em1 bandwidth 200M max 200M default

queue att on em2 bandwidth 300M max 300M default

match on em0 set queue l3

match on em1 set queue ntt

match on em2 set quete att

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (11)

MATH FOR BANDWIDTH CALCULATION

Physical interface speed(bps) / (frame size(B) * 8 (B to b)) = packets per second *

Frame size 84 to 1538 bytes (no vlan’s or Q in Q)

1,000,000,000 bps / (84 * 8) = 1,488,096

1,000,000,000 bps / (1538 * 8) = 81,274

* For a single direction on a single interface

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (12)

MATH FOR BANDWIDTH CALCULATION

TCP ACK bandwidth

Incoming PPS with largest frame size * 66 bytes * 8 = outgoing ACK space in bps

81,274 * 66 * 8 = 42,912,672 bps

UDP Space

DNS 1 to 5% of upstream

VoIP stuff into bulk or default with higher priority or carve out space by defining a queue and assign rules

Queue Space

Make sure the sum of bandwidth specified on child queues does not exceed the root queue

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (13)

SPECIFYING QUEUS’S

set queue qname or set queue (qname , qname)

add to block, match or pass rules

Pass rules: incoming (my preference) or no direction specified

Match rules: any or no direction specified

Block rules: any direction

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (14)

SETTING PRIORITIES

• PF allows priorities to be set on packets via their matching rule

• 0 – 7, higher the number higher the priority

• Default priority if none is specified is 3

• Packets with a higher priority are processed before lower priorities

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (15)

PRIORITIES

• set prio # or set prio (# , #)

• You can operate with the minimum of 1 queues and rules to set priorities.

queue root on em0 bandwidth 10M max 10M default

match out on em0 proto tcp set prio (3,6)

match out on egress proto {tcp,udp} from any to any port 53 set prio 7

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (16)

CAVEATS

• PF is stateful and queue’s must be set when the state is created

• does not matter which way the traffic is going

• PF will not shape traffic until there is no bandwidth left

• PF will not drop packets until the qlimit(aka qlength) is full *

• If max is not specified on the root queue, pf will allow the bandwidth specified to be

exceeded ( when bandwidth is lower than NIC speed)

• When max is set on child queues, that queue can longer borrow from unused bandwidth

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (17)

CHECKING UP ON THINGS

• systat q

• Will show the queue tree and it’s current snapshot updated every second

• pfctl –vvs queue

• Different layout more info also updated every 5 seconds

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (18)

TROUBLESHOOTING

• Traffic being wrongly classified or dropped where it shouldn’t be

• Add log to the rules that specify the queues

tcpdump –nettr /var/log/pflog

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (19)

QUESTIONS

• ?

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (20)

BY JIM HOFFMANjim (at) securebytes.org

Pf Queuing - ChiBUG· PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (21)

REFERENCES

1) Hansteen, Peter N.M. The Book of PF: A No-Nonsense Guide to the OpenBSD

Firewall; 3rd Edition. N.p.: No Starch, 2014. 123. Print.

Pf Queuing - ChiBUG · PF QUEUING FOR OPENBSD 5.5 AND NEWER. HISTORY ... WEB SERVER queue root on em0 ... from any to any port 53 set queue dns set prio 7 - [PDF Document] (2024)
Top Articles
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 6038

Rating: 4.7 / 5 (77 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.