pub struct NatConfig {
pub flags: u16,
pub ipv4_min: Option<Ipv4Addr>,
pub ipv4_max: Option<Ipv4Addr>,
pub ipv6_min: Option<Ipv6Addr>,
pub ipv6_max: Option<Ipv6Addr>,
pub port_min: Option<u16>,
pub port_max: Option<u16>,
}Expand description
NAT configuration for use with ct() action.
§Examples
ⓘ
// SNAT to a single IP
NatConfig::snat(Ipv4Addr::new(10, 0, 0, 1))
// SNAT with IP range
NatConfig::snat_range(
Ipv4Addr::new(10, 0, 0, 1),
Ipv4Addr::new(10, 0, 0, 10),
)
// DNAT with port
NatConfig::dnat(Ipv4Addr::new(192, 168, 1, 1)).port(8080)
// SNAT with port range and random selection
NatConfig::snat(Ipv4Addr::new(10, 0, 0, 1))
.port_range(5000, 6000)
.random()Fields§
§flags: u16NAT flags (SRC/DST, persistent, hash, random)
ipv4_min: Option<Ipv4Addr>Minimum IPv4 address (if IPv4 NAT)
ipv4_max: Option<Ipv4Addr>Maximum IPv4 address (if range)
ipv6_min: Option<Ipv6Addr>Minimum IPv6 address (if IPv6 NAT)
ipv6_max: Option<Ipv6Addr>Maximum IPv6 address (if range)
port_min: Option<u16>Minimum port (if port NAT)
port_max: Option<u16>Maximum port (if port range)
Implementations§
Source§impl NatConfig
impl NatConfig
Sourcepub fn snat_range(min: Ipv4Addr, max: Ipv4Addr) -> Self
pub fn snat_range(min: Ipv4Addr, max: Ipv4Addr) -> Self
Create a SNAT configuration with an IPv4 address range.
Sourcepub fn dnat_range(min: Ipv4Addr, max: Ipv4Addr) -> Self
pub fn dnat_range(min: Ipv4Addr, max: Ipv4Addr) -> Self
Create a DNAT configuration with an IPv4 address range.
Sourcepub fn snat_v6_range(min: Ipv6Addr, max: Ipv6Addr) -> Self
pub fn snat_v6_range(min: Ipv6Addr, max: Ipv6Addr) -> Self
Create a SNAT configuration with an IPv6 address range.
Sourcepub fn dnat_v6_range(min: Ipv6Addr, max: Ipv6Addr) -> Self
pub fn dnat_v6_range(min: Ipv6Addr, max: Ipv6Addr) -> Self
Create a DNAT configuration with an IPv6 address range.
Sourcepub fn port_range(self, min: u16, max: u16) -> Self
pub fn port_range(self, min: u16, max: u16) -> Self
Set a port range for NAT.
Sourcepub fn persistent(self) -> Self
pub fn persistent(self) -> Self
Use persistent NAT mapping (survives restarts).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NatConfig
impl RefUnwindSafe for NatConfig
impl Send for NatConfig
impl Sync for NatConfig
impl Unpin for NatConfig
impl UnsafeUnpin for NatConfig
impl UnwindSafe for NatConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more