MacMatch

Example:

>>> from linuxnet.iptables import MacMatch
>>> m = MacMatch()
>>> m.mac_source().equals('12:34:56:78:9a:bc')
<linuxnet.iptables.matches.macmatch.MacMatch object at 0x7fea123bc278>
>>> m.to_iptables_args()
['-m', 'mac', '--mac-source', '12:34:56:78:9A:BC']
class MacMatch[source]

This class provides matching against the source MAC address

static get_match_name() str[source]

Returns the iptables(8) match extension name.

get_criteria() Iterable[Criterion][source]

Returns the packet match criteria; in this case, it is only the MAC source address criterion

mac_source() MacSourceCriterion[source]

Match against the source address


MacSourceCriterion

class MacSourceCriterion(match: Match)[source]

Compare with the MAC source address.

The comparison value is an upper-case string

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).

equals(value) Match

Compare with the specified value

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: 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.