TtlMatch¶
Example:
>>> from linuxnet.iptables import TtlMatch
>>> m = TtlMatch()
>>> m.ttl().not_equals(32)
<linuxnet.iptables.match.TtlMatch object at 0x7ff96e466f60>
>>> m.to_iptables_args()
['-m', 'ttl', '!', '--ttl-eq', '32']
>>> m = TtlMatch()
>>> m.ttl().less_than(32)
<linuxnet.iptables.match.TtlMatch object at 0x7ff96e466fd0>
>>> m.to_iptables_args()
['-m', 'ttl', '--ttl-lt', '32']
- class TtlMatch[source]¶
Match against the packet TTL value
- ttl() TtlCriterion[source]¶
Returns the TTL criterion
TtlCriterion¶
- class TtlCriterion(match: Match)[source]¶
A criterion for a TTL value comparison used by
TtlMatch.- get_value() Tuple[int, str][source]¶
Returns the value that the criterion is comparing against and the comparison operation (as a string)
- Return type:
tuple of (int, str)
- equals(value: int) Match[source]¶
Check if the packet TTL is equal to
value- Parameters:
value – the TTL value
- less_than(value: int) Match[source]¶
Check if the packet TTL is less than
value- Parameters:
value – the TTL value
- greater_than(value: int) Match[source]¶
Check if the packet TTL is greater than
value- Parameters:
value – the TTL value
- 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