ConntrackMatch¶
Example:
>>> from linuxnet.iptables import ConntrackMatch
>>> m = ConntrackMatch()
>>> m.ctstate().equals('NEW')
<linuxnet.iptables.matches.conntrackmatch.ConntrackMatch object at 0x7ffab737e208>
>>> m.to_iptables_args()
['-m', 'conntrack', '--ctstate', 'NEW']
- class ConntrackMatch[source]¶
Match against the connection tracking attributes.
- ctstate() CtStateCriterion[source]¶
Match against the connection tracking state
- ctstatus() CtStatusCriterion[source]¶
Matching against the connection tracking status
- ctdir() CtDirectionCriterion[source]¶
Matching against the connection tracking status
- ctproto() ProtocolCriterion[source]¶
Matching against the L4 protocol
- ctorigsrc() CtOrigSrcCriterion[source]¶
Matching against the origin’s source IP address
- ctorigdst() CtOrigDstCriterion[source]¶
Matching against the origin’s destination IP address
- ctreplsrc() CtReplSrcCriterion[source]¶
Matching against the reply’s source IP address
- ctrepldst() CtReplDstCriterion[source]¶
Matching against the reply’s destination IP address
- ctorigsrcport() CtOrigSrcPortCriterion[source]¶
Matching against the origin’s source port
- ctorigdstport() CtOrigDstPortCriterion[source]¶
Matching against the origin’s destination port
- ctreplsrcport() CtReplSrcPortCriterion[source]¶
Matching against the replin’s source port
- ctrepldstport() CtReplDstPortCriterion[source]¶
Matching against the replin’s destination port
- ctexpire() CtExpireCriterion[source]¶
Matching against the replin’s destination port
CtStateCriterion¶
- class CtStateCriterion(match)[source]¶
Compare against the connection tracking state
The comparison value is a string.
- 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).
- get_iptables_option() str¶
Returns the iptables(8) option
- get_value() Any¶
Returns the criterion value
- 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
CtStatusCriterion¶
- class CtStatusCriterion(match)[source]¶
Compare against the connection tracking status
The comparison value is a string.
- 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).
- get_iptables_option() str¶
Returns the iptables(8) option
- get_value() Any¶
Returns the criterion value
- 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
CtDirectionCriterion¶
- class CtDirectionCriterion(match)[source]¶
Compare against the connection tracking direction
The comparison value is a string.
- 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).
- get_iptables_option() str¶
Returns the iptables(8) option
- get_value() Any¶
Returns the criterion value
- 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
- not_equals(*args, **kwargs)¶
Indicates that negation is not supported by raising an
IptablesError
CtOrigSrcCriterion¶
- class CtOrigSrcCriterion(match: Match, *, ipv6: Optional[bool] = None)[source]¶
Compare against the origin’s source IP address.
The comparison value is an
IPv4Networkor anIPv6Network- 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).
- equals(value: Union[IPv4Network, IPv6Network, IPv4Address, IPv6Address, str]) Match¶
Compare with the specified value, which can be specified as an
IPv4Network, anIPv6Network, anIPv4Address, anIPv6Address, or as a string. Internally the value is always stored as anIPv4Network, or anIPv6Network.
- get_iptables_option() str¶
Returns the iptables(8) option
- get_value() Optional[Union[IPv4Network, IPv6Network]]¶
Returns the criterion value
- 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
CtOrigDstCriterion¶
- class CtOrigDstCriterion(match: Match, *, ipv6: Optional[bool] = None)[source]¶
Compare against the origin’s destination IP address.
The comparison value is an
IPv4Networkor anIPv6Network- 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).
- equals(value: Union[IPv4Network, IPv6Network, IPv4Address, IPv6Address, str]) Match¶
Compare with the specified value, which can be specified as an
IPv4Network, anIPv6Network, anIPv4Address, anIPv6Address, or as a string. Internally the value is always stored as anIPv4Network, or anIPv6Network.
- get_iptables_option() str¶
Returns the iptables(8) option
- get_value() Optional[Union[IPv4Network, IPv6Network]]¶
Returns the criterion value
- 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
CtReplSrcCriterion¶
- class CtReplSrcCriterion(match: Match, *, ipv6: Optional[bool] = None)[source]¶
Compare against the reply’s source IP address.
The comparison value is an
IPv4Networkor anIPv6Network- 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).
- equals(value: Union[IPv4Network, IPv6Network, IPv4Address, IPv6Address, str]) Match¶
Compare with the specified value, which can be specified as an
IPv4Network, anIPv6Network, anIPv4Address, anIPv6Address, or as a string. Internally the value is always stored as anIPv4Network, or anIPv6Network.
- get_iptables_option() str¶
Returns the iptables(8) option
- get_value() Optional[Union[IPv4Network, IPv6Network]]¶
Returns the criterion value
- 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
CtReplDstCriterion¶
- class CtReplDstCriterion(match: Match, *, ipv6: Optional[bool] = None)[source]¶
Compare against the reply’s destination IP address.
The comparison value is an
IPv4Networkor anIPv6Network- 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).
- equals(value: Union[IPv4Network, IPv6Network, IPv4Address, IPv6Address, str]) Match¶
Compare with the specified value, which can be specified as an
IPv4Network, anIPv6Network, anIPv4Address, anIPv6Address, or as a string. Internally the value is always stored as anIPv4Network, or anIPv6Network.
- get_iptables_option() str¶
Returns the iptables(8) option
- get_value() Optional[Union[IPv4Network, IPv6Network]]¶
Returns the criterion value
- 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
CtOrigSrcPortCriterion¶
- class CtOrigSrcPortCriterion(match: Match)[source]¶
Compare against the origin’s source port (or port range).
The comparison value is the tuple (port, last_port) where last_port may be
None- 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).
- equals(first: int, last: Optional[int] = None) Match¶
Compare with a number (or inclusion in number-range if
lastis present)
- get_value() Tuple[int, Optional[int]]¶
Returns the value that the criterion is comparing against
- Return type:
a tuple of (int, int|None)
- 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
CtOrigDstPortCriterion¶
- class CtOrigDstPortCriterion(match: Match)[source]¶
Compare against the origin’s destination port (or port range).
The comparison value is the tuple (port, last_port) where last_port may be
None- 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).
- equals(first: int, last: Optional[int] = None) Match¶
Compare with a number (or inclusion in number-range if
lastis present)
- get_value() Tuple[int, Optional[int]]¶
Returns the value that the criterion is comparing against
- Return type:
a tuple of (int, int|None)
- 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
CtReplSrcPortCriterion¶
- class CtReplSrcPortCriterion(match: Match)[source]¶
Compare against the reply’s source port (or port range).
The comparison value is the tuple (port, last_port) where last_port may be
None- 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).
- equals(first: int, last: Optional[int] = None) Match¶
Compare with a number (or inclusion in number-range if
lastis present)
- get_value() Tuple[int, Optional[int]]¶
Returns the value that the criterion is comparing against
- Return type:
a tuple of (int, int|None)
- 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
CtReplDstPortCriterion¶
- class CtReplDstPortCriterion(match: Match)[source]¶
Compare against the origin’s destination port (or port range).
The comparison value is the tuple (port, last_port) where last_port may be
None- 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).
- equals(first: int, last: Optional[int] = None) Match¶
Compare with a number (or inclusion in number-range if
lastis present)
- get_value() Tuple[int, Optional[int]]¶
Returns the value that the criterion is comparing against
- Return type:
a tuple of (int, int|None)
- 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
CtExpireCriterion¶
- class CtExpireCriterion(match: Match)[source]¶
Compare against the remaining lifetime of the connection tracking
The comparison value is the tuple (time, end_time) where end_time may be
None(time is measured in seconds)- 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).
- equals(first: int, last: Optional[int] = None) Match¶
Compare with a number (or inclusion in number-range if
lastis present)
- get_value() Tuple[int, Optional[int]]¶
Returns the value that the criterion is comparing against
- Return type:
a tuple of (int, int|None)
- 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