Книга: Iptables Tutorial 1.2.2

Multiport match

Multiport match

The multiport match extension can be used to specify multiple destination ports and port ranges. Without the possibility this match gives, you would have to use multiple rules of the same type, just to match different ports.

Note You can not use both standard port matching and multiport matching at the same time, for example you can't write: --sport 1024:63353 -m multiport --dport 21,23,80. This will simply not work. What in fact happens, if you do, is that iptables honors the first element in the rule, and ignores the multiport instruction.

Table 10-23. Multiport match options

Match --source-port
Kernel 2.3, 2.4, 2.5 and 2.6
Example iptables -A INPUT -p tcp -m multiport --source-port 22,53,80,110
Explanation This match matches multiple source ports. A maximum of 15 separate ports may be specified. The ports must be comma delimited, as in the above example. The match may only be used in conjunction with the -p tcp or -p udp matches. It is mainly an enhanced version of the normal --source-port match.
Match --destination-port
Kernel 2.3, 2.4, 2.5 and 2.6
Example iptables -A INPUT -p tcp -m multiport --destination-port 22,53,80,110
Explanation This match is used to match multiple destination ports. It works exactly the same way as the above mentioned source port match, except that it matches destination ports. It too has a limit of 15 ports and may only be used in conjunction with -p tcp and -p udp.
Match --port
Kernel 2.3, 2.4, 2.5 and 2.6
Example iptables -A INPUT -p tcp -m multiport --port 22,53,80,110
Explanation This match extension can be used to match packets based both on their destination port and their source port. It works the same way as the --source-port and --destination-port matches above. It can take a maximum of 15 ports and can only be used in conjunction with -p tcp and -p udp. Note that the --port match will only match packets coming in from and going to the same port, for example, port 80 to port 80, port 110 to port 110 and so on.

Оглавление книги


Генерация: 0.790. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз