Paketpriorisierung mit PF und ALTQ

I.MC

Watt soll denn hier hin?
Hi,

ich versuche hier eine vernünftige Paketpriorisierung gewisser Anwendungen zu erreichen, wobei ich jedoch auf einige Probleme stoße. Evtl. sind dies einfach die Grenzen des ALTQ, ich weiss es nicht. Erst einmal die relevanten Regeln:

Code:
##################################################
#QoS                                                                                                                                                                                                                                                #                                                                                   
##################################################
altq on $dsl_device cbq bandwidth 120Kb queue { std, high_prio, low_prio  }
queue std priority 3 cbq ( default )
queue high_prio bandwidth 100Kb priority 7 cbq ( borrow )
queue low_prio bandwidth 20Kb priority 0 cbq ( borrow )


##################################################
# Paketmodifizierung - NAT-Regeln (Portforwarding)                                                                                                   #
##################################################
nat on $dsl_device from $lan to any -> ($dsl_device)


##################################################
# Filterregeln                                                                                                                                       #
##################################################
pass out quick on $dsl_device inet proto icmp from ($dsl_device) to any keep state queue high_prio
pass out quick on $dsl_device proto udp from ($dsl_device) to any port 53 keep state queue high_prio
pass out quick on $dsl_device proto {tcp, udp} from ($dsl_device) to any port 27000:28000 keep state queue(high_prio, high_prio)
pass out quick on $dsl_device from ($dsl_device) to any keep state queue ( low_prio, high_prio ) 
pass in quick on $dsl_device inet proto icmp all icmp-type 8 keep state

Ich möchte also bis jetzt ausgehende DNS Anfragen, das ICMP Protokoll und TCP/UDP Verbindungen zu den Ports 27000-28000 mit höchster Priorität betreiben, alles andere mit niedrigster (abgesehen von ACK Paketen). Interessant sind im Moment am meisten die Verbindungen zu den Ports 27000-28000, da diese für das Online-Spielen von Quake III wichtig sind. Soweit so gut, nun habe ich aber hier einen Mldonkey laufen, der sichtbar die Pakete für Quake beeinflusst. Eigentlich sollte laut Regeln aber alles, was der macht mit niedrigster Priorität laufen. Jetzt frage ich mich, wie kann ich die Regeln umstellen, dass diese Prioritäten besser eingehalten werden?

Gruß, I.MC
 
Probier doch mal separate scheduler und bandwidths für ausgehende Packete auf dem externen Interface und eingehende Packete vom internen Interface.

Beispiel (aus der OpenBSD PF FAQ):

Code:
# 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
 
Ich habe jetzt mal den MldonkeyServer voll ausgebremst auf 1kb/s up und 60kb/s down. Zudem habe ich dessen Prio mittels cbq ganz nach unter gedreht auf den internen Interface des Routers, der Rest der internen Rechner hat hohe Prio. Auf dem externen Dsl interface habe ich cbq und priq ausprobiert mit obigen Regeln. Also das hilft alles nichts, wenn jemand anfängt mit 60 kb/s zu laden, dann bricht der ping ein, obwohl noch 50% der Leitung frei sind. Ich würde einfach jetzt gerne wissen, ob das technisch überhaupt realistisch ist den selben niedrigen ping zu haben wenn die Leitung in eine Richtung z.B. mit 50% Last läuft... dann hätte sich das alles direkt erledight hier. Ich meine ohne QoS ist es noch viel schlimmer :-)

Gruß, I.MC
 
Back
Top