DnatTarget

class DnatTarget(*, addr=None, port=None, last_port=None, is_random=False, is_persistent=False)[source]

This class provides access to the DNAT target

Parameters:
  • addr – an IPv4Address object

  • port – port number (integer)

  • last_port – port number (integer) used when defining a port range

  • is_random – if True, use the iptables(8) --random option

  • is_persistent – if True, use the iptables(8) --persistent option

get_address() Optional[IPv4Address]

Returns the address used for [SD]NAT

to_iptables_args() List[str]

Returns a list of iptables(8) arguments