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

static get_match_name()[source]

Returns the iptables(8) match extension name

get_criteria() Iterable[Criterion][source]

Returns the TTL match criteria (only one).

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 Criterion in 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() (or not_equals()) with args and kwargs if is_equal is True (or False).

is_positive() bool

Returns the ‘polarity’ of the criterion: True for equals() or False for not_equals()

Raises IptablesError if the criterion is not set

is_set() bool

Returns True if the criterion has been set

not_equals(*args, **kwargs) Match

Express inequality comparison against the argument values.

The arguments of this method are the same as those of the equals() method.

This method invokes the equals() method and then reverses the polarity.

Returns this Match object.