SnatTarget¶
- class SnatTarget(*, addr: Optional[Union[IPv4Address, IPv6Address]] = None, port: Optional[int] = None, last_port: Optional[int] = None, is_random=False, is_fully_random=False, is_persistent=False)[source]¶
This class provides access to the
SNATtarget- Parameters:
addr – an
IPv4AddressorIPv6Addressinstanceport – port number (integer)
last_port – port number (integer) used when defining a port range
is_random – if
True, use the iptables(8)--randomoptionis_fully_random – if
True, use the iptables(8)--random-fullyoptionis_persistent – if
True, use the iptables(8)--persistentoption
- get_address() Optional[Union[IPv4Address, IPv6Address]]¶
Returns the address used as the new source address (in the case of
SNAT) or destination address (in the caseDNAT).
- get_ports() Tuple[Optional[int], Optional[int]]¶
Returns the port range used for NATing.
- get_target_name() str¶
Returns the target name
- is_persistent() bool¶
Returns
Truewhen persistent port mapping is enabled
- is_random() bool¶
Returns
Truewhen random port mapping is enabled
- is_terminating() bool¶
Returns
Trueif this is a terminating target
- set_address(addr: Union[IPv4Address, IPv6Address]) None¶
Set the address
- set_persistent() None¶
Enable persistent port mapping
- set_port(port: int) None¶
Set the port
- set_port_range(port: int, last_port: int) None¶
Set the port range
- set_random() None¶
Enable randomized port mapping