MultiportMatch¶
The MultiportMatch class provides access to the
multiport match extension.
Example:
>>> from linuxnet.iptables import MultiportMatch
>>> m = MultiportMatch()
>>> m.source_ports().equals((80, 443, (8080,8089)))
<linuxnet.iptables.matches.multiportmatch.MultiportMatch object at 0x7f4f773d4e20>
>>> m.to_iptables_args()
['-m', 'multiport', '--source-ports', '80,443,8080:8089']
- class MultiportMatch[source]¶
Match against sets of TCP/UDP ports.
- get_criteria() Iterable[Criterion][source]¶
Returns the multiport match criteria: source-ports, dest-ports, ports
- source_ports() PortsCriterion[source]¶
Criterion with source ports to compare against
- dest_ports() PortsCriterion[source]¶
Criterion with destination ports to compare against
- ports() PortsCriterion[source]¶
Criterion with ports to compare against
PortsCriterion¶
- class PortsCriterion(match: Match, iptables_option: str)[source]¶
Compare against a set of ports.
The value is a tuple; each element of the tuple is either a port number, or a tuple indicating a port range, e.g. (80, 443, (1024, 65536))
- any() Match¶
Match any value.
This method is used when creating a
Criterionin order to search an existing chain for rules that try to match against certain packet properties (e.g. input interface) without being particular about the specific property value (e.g.eth0).
- compare(is_equal: bool, *args, **kwargs) Match¶
Alternative method used for comparisons. It invokes
equals()(ornot_equals()) withargsandkwargsifis_equalisTrue(orFalse).
- is_positive() bool¶
Returns the ‘polarity’ of the criterion:
Trueforequals()orFalsefornot_equals()Raises
IptablesErrorif the criterion is not set
- is_set() bool¶
Returns
Trueif the criterion has been set