PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : iptables erkennt protokolle nicht... ???



ennservogt
08.10.03, 20:18
Servus,
ich suche nun schon Tage nach dem Fehler in folgender iptables Regel:


---ANFANG---

[21:07:16]netserv: /scripts/iptables.rules# iptables -t mangle -A PREROUTING -i eth1 -p tcp,udp --dport 130:140 -j DROP
iptables v1.2.6a: unknown protocol `tcp,udp' specified
Try `iptables -h' or 'iptables --help' for more information.

---ENDE---


Ausschnitt aus der offiziellen iptables Dokumentation:

Match:
-p, --protocol
Example:
iptables -A INPUT -p tcp
Explanation:
This match is used to check for certain protocols. Examples of protocols are TCP, UDP and ICMP. The protocol must either be one of the internally specified TCP, UDP or ICMP. It may also take a value specified in the /etc/protocols file, and if it can not find the protocol there it will reply with an error. The protocl may also be a integer value. For example, the ICMP protocol is integer value 1, TCP is 6 and UDP is 17. Finally, it may also take the value ALL. ALL means that it matches only TCP, UDP and ICMP. The command may also take a comma delimited list of protocols, such as udp,tcp which would match all UDP and TCP packets. If this match is given the integer value of zero (0), it means ALL protocols, which in turn is the default behavior, if the --protocol match is not used. This match can also be inversed with the ! sign, so --protocol ! tcp would mean to match UDP and ICMP.


die anfangszeilen meiner protocols datei:

---ANFANG---

ip 0 IP # internet protocol, pseudo protocol number
icmp 1 ICMP # internet control message protocol
igmp 2 IGMP # Internet Group Management
ggp 3 GGP # gateway-gateway protocol
ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'')
st 5 ST # ST datagram mode
tcp 6 TCP # transmission control protocol
egp 8 EGP # exterior gateway protocol
pup 12 PUP # PARC universal packet protocol
udp 17 UDP # user datagram protocol
hmp 20 HMP # host monitoring protocol

----ENDE---


gekürtzte Ausgabe von lsmod:

---ANFANG---

iptable_filter
iptable_mangle
ipt_MASQUERADE
iptable_nat
ip_conntrack
ip_tables

---ENDE---


Debian Linux mit Kernel 2.4.18-586tsc
iptables iptables v1.2.6a


Ich weis wirklich nicht mehr weiter...

Berufspenner
08.10.03, 20:21
Hi

Trenne mal tcp und udp in deiner Regel. Die Trennung durch das Komma ist ein Syntaxfehler.
iptables -t mangle -A PREROUTING -i eth1 -p tcp --dport 130:140 -j DROP
iptables -t mangle -A PREROUTING -i eth1 -p udp --dport 130:140 -j DROP Cu
André

ennservogt
08.10.03, 20:25
das geht natürlich... nur ich kann es nicht sein dass ich für jeden port drei regeln (tcp,udp,icmp) schreiben muss. das ist dann eine zeit und performancefrage. ausserdem stimmt meine syntax doch laut der manpage.

ich weis jedenfalls nicht mehr weiter....

trotzdem danke für deine antwort!

Berufspenner
08.10.03, 20:37
nur ich kann es nicht sein dass ich für jeden port drei regeln (tcp,udp,icmp) schreiben muss. Dann benutzt doch "ALL". Außerdem wäre es doch eh nur copy & paste.
das ist dann eine [..] performancefrage.Sollte es wirklich zu einer Performanceschwächung führe, so ist diese so gering, dass man sie eh nicht wahrnimmt.
ausserdem stimmt meine syntax doch laut der manpage. Das ist natürlich komisch, denn die Version der Manpage und die von iptables stimmen doch überein, oder?!

Cu
André

HangLoose
08.10.03, 20:39
Original geschrieben von ennservogt
ausserdem stimmt meine syntax doch laut der manpage.



also meine bescheidenen englisch kenntnisse, lassen mich aus der man page was anderes rauslesen.


The protocol must either be one of the internally specified TCP, UDP or ICMP.

ein stück weiter unten steht aber auch, wie du alle 3 protokolle angeben kannst


Finally, it may also take the value ALL. ALL means that it matches only TCP, UDP and ICMP


iptables -t mangle -A PREROUTING -i eth1 -p ALL --dport 130:140 -j DROP


btw. ist es besser, das script so aufzubauen, das erstmal alles verboten wird und anschließend nur das erlaubt wird, was auch wirklich erlaubt sein soll. das hat zwei vorteile => die anzahl der regeln hält sich in grenzen und 2. besteht nicht die gefahr etwas zu übersehen.


Gruß HL

geronet
08.10.03, 20:40
The protocol must either be one of the internally specified TCP, UDP or ICMP.

Edit: da war einer schneller ;)

Grüsse, Stefan

Berufspenner
08.10.03, 20:49
Hi@all

Er meinte wohl diesen Satz
The command may also take a comma delimited list of protocols, such as udp,tcp which would match all UDP and TCP packets. Cu
André

HangLoose
08.10.03, 20:58
Original geschrieben von Berufspenner
Hi@all

Er meinte wohl diesen Satz Cu
André

tatsache, bin ich wohl blind gewesen :D. danach sollte iptables das eigentlich *schlucken*


Gruß HL

ennservogt
08.10.03, 22:42
An den Parameter "all" hab ich natürlich auch schon gedacht, aber
was soll ich sagen:

[23:40:21]netserv: ~# iptables -t mangle -A PREROUTING -i eth1 -p ALL --dport 130:140 -j DROP
iptables v1.2.6a: Unknown arg `--dport'
Try `iptables -h' or 'iptables --help' for more information.

da muß ich doch was primitives übersehen haben...

@Berufspenner: is von www.iptables.org *grins* sollte also schon stimmen

Jinto
09.10.03, 18:11
ALL geht natürlich in dem Fall nicht, ICMP und dports?
Aber wie wäre es mit: ! icmp

@Berufspenner
Den Satz gibt es in meiner manpage nicht.

Berufspenner
09.10.03, 18:21
Original geschrieben von Jinto
@Berufspenner
Den Satz gibt es in meiner manpage nicht. Ich bezog mich dabei auf den Auszug, den ennservogt im Anfangsposting gepostet hat.

Cu
André

Jinto
09.10.03, 18:53
ah jetzt ja, aber da steht may was mich zum schluss führt: es wird derzeit noch nicht unterstützt.

Berufspenner
09.10.03, 18:59
Original geschrieben von Jinto
aber da steht may was mich zum schluss führt: es wird derzeit noch nicht unterstützt. Hä? Also ich würde es jetzt als weitere, mögliche Option deuten.

Cu
André

geronet
09.10.03, 19:23
Das ist das neue "man-page-ahead-developing"-Feature :ugly:

Jinto
11.10.03, 13:13
Original geschrieben von geronet
Das ist das neue "man-page-ahead-developing"-Feature :ugly: Irgendwie hast du damit recht: man-page-ahead (version manpage != Version programm)

@Berufspenner
als "mögliche" Programmoption => kann sein, dass es diesen Parameter gibt. kann aber auch sein, das es ihn nicht gibt. (ich glaub ich bin RFC geschädigt ;) ).