PF regeln fuer bittorrent

MIKQ

Active Member
Ich suche nun seit ca. 2 Stunden eine Lösung zum Thema pf.conf und BiTTorrent insbesondere hier den Client Azureus.


Ich habe sehr viele Forenbeitrage, Newsgroupbeiträge mit dem Problem (Azureus findet Tracker nicht, meckert NAT Probleme an) aber leider nicht eine Lösung.

Schlussendlich habe ich auch die Lösung
HOWTO - DSL Router mit OpenBSD 3.5


probiert musste diese aber schon die Zeile:

InBitTCP = "{ 6969, 6881:6889 }" # Von Bit Torrent benoetigte Ports
pass in quick on $Ext inet proto tcp from any to any port $InBitTCP flags S/SAFR keep state label BitTCP


ändern, da ansonsten pfctl meckert ":" gäbe es nur beim rdr.

Habe es unter anderem so: InBitTCP = "{ 6969, 6881,6882,6883,6884,6889 }" # Von Bit Torrent benoetigte Ports
probiert. Ohne Erfolg.


Die anderen relevanten Zeilen sind also:

Ext = "tun0" # Device an dem das Internet angeschlossen ist
BitIP = "<bittorrent_client>" # IP Adresse des BitTorrent-Clients
IntNet = "192.168.1.0/24" # Adressraum des internen Netzes

rdr on $Ext proto tcp from !$IntNet to any port 6969 -> $BitIP port 6969
rdr on $Ext proto tcp from !$IntNet to any port 6881:6889 -> $BitIP port 6881:*


pfctrl meckert nicht mehr, Overnet läuft z.b. so auch prächtig nur BiTTorrent kommt nicht in die Gänge und Azureus meckert sein NAT Problem an.
Da auch die Geschwindigkeit fehlt und die Tracker nicht sauber gefunden werden ist das Problem nicht rein kosmetischer Natur.
Nur liegt es an Azureus, oder an der pf.ctl? Die Azureus NAT/Router Anleitung hilft (mir) hier auch nicht weiter.

Nun ist jemand gesucht der eine funktionierende Lösung hat und so freundlich wäre diese mitzuteilen. Ich bin sehr sicher das damit nicht nur mir, sondern einer Menge Leute geholfen wäre, denn bisher konnte ich noch keine funktionierende Lösung im Internet finden.
Sachdienliche Hinweise nimmt jede Polizeidienststelle oder wahlweise dieses Forum entgegen.

Grüße

Q
 
nach wochen des rumprobierens hat es bei mir mit dem hier geklappt:

(sorry, keine lust das jetzt zu kommentieren, aber vielleicht hilfts dir...)
Code:
rdr on $inet_if proto { tcp,udp } from any to any port 6881 -> 192.168.23.1 port 6881
rdr on $inet_if proto { tcp,udp } from any to any port 6882 -> 192.168.23.1 port 6882
rdr on $inet_if proto { tcp,udp } from any to any port 6883 -> 192.168.23.1 port 6883
rdr on $inet_if proto { tcp,udp } from any to any port 6884 -> 192.168.23.1 port 6884
rdr on $inet_if proto { tcp,udp } from any to any port 6885 -> 192.168.23.1 port 6885
rdr on $inet_if proto { tcp,udp } from any to any port 6886 -> 192.168.23.1 port 6886
rdr on $inet_if proto { tcp,udp } from any to any port 6887 -> 192.168.23.1 port 6887
rdr on $inet_if proto { tcp,udp } from any to any port 6888 -> 192.168.23.1 port 6888
rdr on $inet_if proto { tcp,udp } from any to any port 6889 -> 192.168.23.1 port 6889
rdr on $inet_if proto { tcp,udp } from any to any port 6890 -> 192.168.23.1 port 6890
rdr on $inet_if proto { tcp,udp } from any to any port 6891 -> 192.168.23.1 port 6891
rdr on $inet_if proto { tcp,udp } from any to any port 6892 -> 192.168.23.1 port 6892
rdr on $inet_if proto { tcp,udp } from any to any port 6893 -> 192.168.23.1 port 6893
rdr on $inet_if proto { tcp,udp } from any to any port 6894 -> 192.168.23.1 port 6894
rdr on $inet_if proto { tcp,udp } from any to any port 6895 -> 192.168.23.1 port 6895
rdr on $inet_if proto { tcp,udp } from any to any port 6896 -> 192.168.23.1 port 6896
rdr on $inet_if proto { tcp,udp } from any to any port 6897 -> 192.168.23.1 port 6897
rdr on $inet_if proto { tcp,udp } from any to any port 6898 -> 192.168.23.1 port 6898
rdr on $inet_if proto { tcp,udp } from any to any port 6899 -> 192.168.23.1 port 6899
rdr on $inet_if proto { tcp,udp } from any to any port 6900 -> 192.168.23.1 port 6900
rdr on $inet_if proto { tcp,udp } from any to any port 6901 -> 192.168.23.1 port 6901
rdr on $inet_if proto { tcp,udp } from any to any port 6902 -> 192.168.23.1 port 6902
rdr on $inet_if proto { tcp,udp } from any to any port 6903 -> 192.168.23.1 port 6903
rdr on $inet_if proto { tcp,udp } from any to any port 6904 -> 192.168.23.1 port 6904
rdr on $inet_if proto { tcp,udp } from any to any port 6905 -> 192.168.23.1 port 6905
rdr on $inet_if proto { tcp,udp } from any to any port 6906 -> 192.168.23.1 port 6906
rdr on $inet_if proto { tcp,udp } from any to any port 6907 -> 192.168.23.1 port 6907
rdr on $inet_if proto { tcp,udp } from any to any port 6908 -> 192.168.23.1 port 6908
rdr on $inet_if proto { tcp,udp } from any to any port 6909 -> 192.168.23.1 port 6909
rdr on $inet_if proto { tcp,udp } from any to any port 6910 -> 192.168.23.1 port 6910
rdr on $inet_if proto { tcp,udp } from any to any port 6911 -> 192.168.23.1 port 6911
rdr on $inet_if proto { tcp,udp } from any to any port 6912 -> 192.168.23.1 port 6912
rdr on $inet_if proto { tcp,udp } from any to any port 6913 -> 192.168.23.1 port 6913
rdr on $inet_if proto { tcp,udp } from any to any port 6914 -> 192.168.23.1 port 6914
rdr on $inet_if proto { tcp,udp } from any to any port 6915 -> 192.168.23.1 port 6915
rdr on $inet_if proto { tcp,udp } from any to any port 6916 -> 192.168.23.1 port 6916
rdr on $inet_if proto { tcp,udp } from any to any port 6917 -> 192.168.23.1 port 6917
rdr on $inet_if proto { tcp,udp } from any to any port 6918 -> 192.168.23.1 port 6918
rdr on $inet_if proto { tcp,udp } from any to any port 6919 -> 192.168.23.1 port 6919
rdr on $inet_if proto { tcp,udp } from any to any port 6920 -> 192.168.23.1 port 6920
rdr on $inet_if proto { tcp,udp } from any to any port 6921 -> 192.168.23.1 port 6921
rdr on $inet_if proto { tcp,udp } from any to any port 6922 -> 192.168.23.1 port 6922
rdr on $inet_if proto { tcp,udp } from any to any port 6923 -> 192.168.23.1 port 6923
rdr on $inet_if proto { tcp,udp } from any to any port 6924 -> 192.168.23.1 port 6924
rdr on $inet_if proto { tcp,udp } from any to any port 6925 -> 192.168.23.1 port 6925
rdr on $inet_if proto { tcp,udp } from any to any port 6926 -> 192.168.23.1 port 6926
rdr on $inet_if proto { tcp,udp } from any to any port 6927 -> 192.168.23.1 port 6927
rdr on $inet_if proto { tcp,udp } from any to any port 6928 -> 192.168.23.1 port 6928
rdr on $inet_if proto { tcp,udp } from any to any port 6929 -> 192.168.23.1 port 6929
rdr on $inet_if proto { tcp,udp } from any to any port 6930 -> 192.168.23.1 port 6930
rdr on $inet_if proto { tcp,udp } from any to any port 6931 -> 192.168.23.1 port 6931
rdr on $inet_if proto { tcp,udp } from any to any port 6932 -> 192.168.23.1 port 6932
rdr on $inet_if proto { tcp,udp } from any to any port 6933 -> 192.168.23.1 port 6933
rdr on $inet_if proto { tcp,udp } from any to any port 6934 -> 192.168.23.1 port 6934
rdr on $inet_if proto { tcp,udp } from any to any port 6935 -> 192.168.23.1 port 6935
rdr on $inet_if proto { tcp,udp } from any to any port 6936 -> 192.168.23.1 port 6936
rdr on $inet_if proto { tcp,udp } from any to any port 6937 -> 192.168.23.1 port 6937
rdr on $inet_if proto { tcp,udp } from any to any port 6938 -> 192.168.23.1 port 6938
rdr on $inet_if proto { tcp,udp } from any to any port 6939 -> 192.168.23.1 port 6939
rdr on $inet_if proto { tcp,udp } from any to any port 6940 -> 192.168.23.1 port 6940
rdr on $inet_if proto { tcp,udp } from any to any port 6941 -> 192.168.23.1 port 6941
rdr on $inet_if proto { tcp,udp } from any to any port 6942 -> 192.168.23.1 port 6942
rdr on $inet_if proto { tcp,udp } from any to any port 6943 -> 192.168.23.1 port 6943
rdr on $inet_if proto { tcp,udp } from any to any port 6944 -> 192.168.23.1 port 6944
rdr on $inet_if proto { tcp,udp } from any to any port 6945 -> 192.168.23.1 port 6945
rdr on $inet_if proto { tcp,udp } from any to any port 6946 -> 192.168.23.1 port 6946
rdr on $inet_if proto { tcp,udp } from any to any port 6947 -> 192.168.23.1 port 6947
rdr on $inet_if proto { tcp,udp } from any to any port 6948 -> 192.168.23.1 port 6948
rdr on $inet_if proto { tcp,udp } from any to any port 6949 -> 192.168.23.1 port 6949
rdr on $inet_if proto { tcp,udp } from any to any port 6950 -> 192.168.23.1 port 6950
rdr on $inet_if proto { tcp,udp } from any to any port 6951 -> 192.168.23.1 port 6951
rdr on $inet_if proto { tcp,udp } from any to any port 6952 -> 192.168.23.1 port 6952
rdr on $inet_if proto { tcp,udp } from any to any port 6953 -> 192.168.23.1 port 6953
rdr on $inet_if proto { tcp,udp } from any to any port 6954 -> 192.168.23.1 port 6954
rdr on $inet_if proto { tcp,udp } from any to any port 6955 -> 192.168.23.1 port 6955
rdr on $inet_if proto { tcp,udp } from any to any port 6956 -> 192.168.23.1 port 6956
rdr on $inet_if proto { tcp,udp } from any to any port 6957 -> 192.168.23.1 port 6957
rdr on $inet_if proto { tcp,udp } from any to any port 6958 -> 192.168.23.1 port 6958
rdr on $inet_if proto { tcp,udp } from any to any port 6959 -> 192.168.23.1 port 6959
rdr on $inet_if proto { tcp,udp } from any to any port 6960 -> 192.168.23.1 port 6960
rdr on $inet_if proto { tcp,udp } from any to any port 6961 -> 192.168.23.1 port 6961
rdr on $inet_if proto { tcp,udp } from any to any port 6962 -> 192.168.23.1 port 6962
rdr on $inet_if proto { tcp,udp } from any to any port 6963 -> 192.168.23.1 port 6963
rdr on $inet_if proto { tcp,udp } from any to any port 6964 -> 192.168.23.1 port 6964
rdr on $inet_if proto { tcp,udp } from any to any port 6965 -> 192.168.23.1 port 6965
rdr on $inet_if proto { tcp,udp } from any to any port 6966 -> 192.168.23.1 port 6966
rdr on $inet_if proto { tcp,udp } from any to any port 6967 -> 192.168.23.1 port 6967
rdr on $inet_if proto { tcp,udp } from any to any port 6968 -> 192.168.23.1 port 6968
rdr on $inet_if proto { tcp,udp } from any to any port 6969 -> 192.168.23.1 port 6969
rdr on $inet_if proto { tcp,udp } from any to any port 6970 -> 192.168.23.1 port 6970
rdr on $inet_if proto { tcp,udp } from any to any port 6971 -> 192.168.23.1 port 6971
rdr on $inet_if proto { tcp,udp } from any to any port 6972 -> 192.168.23.1 port 6972
rdr on $inet_if proto { tcp,udp } from any to any port 6973 -> 192.168.23.1 port 6973
rdr on $inet_if proto { tcp,udp } from any to any port 6974 -> 192.168.23.1 port 6974
rdr on $inet_if proto { tcp,udp } from any to any port 6975 -> 192.168.23.1 port 6975
rdr on $inet_if proto { tcp,udp } from any to any port 6976 -> 192.168.23.1 port 6976
rdr on $inet_if proto { tcp,udp } from any to any port 6977 -> 192.168.23.1 port 6977
rdr on $inet_if proto { tcp,udp } from any to any port 6978 -> 192.168.23.1 port 6978
rdr on $inet_if proto { tcp,udp } from any to any port 6979 -> 192.168.23.1 port 6979
rdr on $inet_if proto { tcp,udp } from any to any port 6980 -> 192.168.23.1 port 6980
rdr on $inet_if proto { tcp,udp } from any to any port 6981 -> 192.168.23.1 port 6981
rdr on $inet_if proto { tcp,udp } from any to any port 6982 -> 192.168.23.1 port 6982
rdr on $inet_if proto { tcp,udp } from any to any port 6983 -> 192.168.23.1 port 6983
rdr on $inet_if proto { tcp,udp } from any to any port 6984 -> 192.168.23.1 port 6984
rdr on $inet_if proto { tcp,udp } from any to any port 6985 -> 192.168.23.1 port 6985
rdr on $inet_if proto { tcp,udp } from any to any port 6986 -> 192.168.23.1 port 6986
rdr on $inet_if proto { tcp,udp } from any to any port 6987 -> 192.168.23.1 port 6987
rdr on $inet_if proto { tcp,udp } from any to any port 6988 -> 192.168.23.1 port 6988
rdr on $inet_if proto { tcp,udp } from any to any port 6989 -> 192.168.23.1 port 6989
rdr on $inet_if proto { tcp,udp } from any to any port 6990 -> 192.168.23.1 port 6990
rdr on $inet_if proto { tcp,udp } from any to any port 6991 -> 192.168.23.1 port 6991
rdr on $inet_if proto { tcp,udp } from any to any port 6992 -> 192.168.23.1 port 6992
rdr on $inet_if proto { tcp,udp } from any to any port 6993 -> 192.168.23.1 port 6993
rdr on $inet_if proto { tcp,udp } from any to any port 6994 -> 192.168.23.1 port 6994
rdr on $inet_if proto { tcp,udp } from any to any port 6995 -> 192.168.23.1 port 6995
rdr on $inet_if proto { tcp,udp } from any to any port 6996 -> 192.168.23.1 port 6996
rdr on $inet_if proto { tcp,udp } from any to any port 6997 -> 192.168.23.1 port 6997
rdr on $inet_if proto { tcp,udp } from any to any port 6998 -> 192.168.23.1 port 6998
rdr on $inet_if proto { tcp,udp } from any to any port 6999 -> 192.168.23.1 port 6999
...
...
...

pass in quick inet proto tcp from any to any port { 31337, 6881,6882,6883,6884,6885,6886,6887,6888,6889,6890,6891,6892,6893,6894,6895,6896,6897,6898,6899,6900,6901,6902,6903,6904,6905,6906,6907,6908,6909,6910,6911,6912,6913,6914,6915,6916,6917,6918,6919,6920,6921,6922,6923,6924,6925,6926,6927,6928,6929,6930,6931,6932,6933,6934,6935,6936,6937,6938,6939,6940,6941,6942,6943,6944,6945,6946,6947,6948,6949,6950,6951,6952,6953,6954,6955,6956,6957,6958,6959,6960,6961,6962,6963,6964,6965,6966,6967,6968,6969,6970,6971,6972,6973,6974,6975,6976,6977,6978,6979,6980,6981,6982,6983,6984,6985,6986,6987,6988,6989,6990,6991,6992,6993,6994,6995,6996,6997,6998,6999,8080, 22 } 
...
...
 
Meine Regeln sehen so aus, damit funktioniert es bei mir tadellos:

Code:
# macros
ext 		= "pppoe0"
int 		= "sis0"
nic1		= "{" lo0 $int "}"
nic2		= "{" lo0 $int $ext "}"
localhost 	= "127.0.0.1"
machine1	= "10.255.255.190"
machine2         = "10.255.255.170"
lan		= "10.255.255.160/27"
udpports	= "{" echo domain ntp "}"
p2pport            = "58782"
p2pudp	= "62489"
ks		= "keep state"
ms		= "flags S/SA modulate state"
ss		= "flags S/SA synproxy state"

# tables
table <p2p> file "/etc/pf/tables/p2p"

# options
set block-policy drop
set optimization aggressive
set loginterface $ext
set fingerprints "/etc/pf/pf.os"
set limit { states 10000 frags 10000 src-nodes 2000 }
set timeout { tcp.established 180 }

# scrub
scrub in

# altq

# nat/rdr
nat on $ext from $int:network to any -> ($ext)
rdr on $ext proto tcp from !$lan to any port $p2pport -> $machine2 port $p2pport

# filter rules
block log
block quick inet6
pass on $nic1
#antispoof quick log for $nic2 inet
block in quick on $ext proto tcp from <spammer>
block out quick on $ext proto tcp to <spammer>
block in quick on $ext from <p2p>
block out quick on $ext to <p2p>
pass out on $ext proto tcp $ms
pass out on $ext proto tcp from any port $p2pport to any $ms
pass in on $ext proto tcp from any to any port $p2pport $ss \
	(max-src-conn-rate 50/30, overload <spammer> flush global)
pass out on $ext proto udp from any to any port { domain ntp } $ks
pass out on $ext proto udp from any port $p2pudp to any $ks
pass in on $ext proto udp from any to any port $p2pudp $ks

Musst du natürlich an deine Verhältnisse vor Ort anpassen. ;-))
 
Welche OpenBSD Version verwendest du? Seit 3.5 haben sich Teile der pf Syntax geändert. Wenn du neueres OpenBSD als 3.5 hast wird dir diese Anleitung da oben nichts helfen (mit 3.6 dürfts noch gehen, iirc war die Änderung zwischen 3.6 und 3.7).

Stell in Azureus den Bereich ein, den es für Trackerverbindungen verwenden soll (--minport= --maxport= beim Python CLI Client) und redirecte diese auf die Kiste auf der Azureus läuft.
Die Syntax hierzu steht in der manpage. Das is keine Magie.
 
Verwende noch 3.5 und hatte vor die Regeln von quantumleeks auszuprobieren.

Ich hoffe Elessar ich verstehe dich jetzt richtig, afaik kannst Du beim NAT Test in Azerus gleichzeitig den Tracker Port ändern, bzw. habe ich das im GUI -> Konfiguration getan. (Erste Option ganz oben)
Mein:
rdr on $Ext proto tcp from !$IntNet to any port 6969 -> $BitIP port 6969

Sollte dem Tracker Rechnung tragen. (ok ist der Standard Port für den Tracker.)

Zusätzlich habe ich die nachweislich für Overnet funktionierenden Ports mal für BiTTorrent "mißbraucht" und z.B. im Tracker eingetragen.

Geholfen hat es alles nicht.
Gruß
Q
 
Zurück
Oben