Targets

All target-related classes are derived from the Target class.

The helper class Targets provides access to the special targets (e.g. ACCEPT).


class Target(target_name: str, terminates: bool)[source]

Parent class for all targets.

Parameters:
  • target_name – the name of the target

  • terminates – if True, this target terminates processing

get_target_name() str[source]

Returns the target name

is_terminating() bool[source]

Returns True if this is a terminating target

to_iptables_args() List[str][source]

Returns a list of iptables(8) arguments


class Targets[source]

This class provides a namespace for all target classes

ACCEPT = <linuxnet.iptables.target.Target object>

Special ACCEPT target

DROP = <linuxnet.iptables.target.Target object>

Special DROP target

QUEUE = <linuxnet.iptables.target.Target object>

Special QUEUE target

RETURN = <linuxnet.iptables.target.Target object>

Special RETURN target

classmethod get_special(target_name: str) Optional[Target][source]

Returns the Target object for the special target identified by target_name.

The special targets are:

  • ACCEPT

  • DROP

  • RETURN

  • QUEUE

classmethod from_policy(policy: str) Target[source]

Return the Target object for one the special targets that can be used as a policy target. These include:

  • ACCEPT

  • DROP

  • QUEUE