Nat ICMP
This commit is contained in:
parent
f0c2d3bf50
commit
578d5aa51a
1 changed files with 16 additions and 16 deletions
18
firewall.py
18
firewall.py
|
@ -607,6 +607,12 @@ def get_ip_iterable_from_str(ip):
|
|||
|
||||
class NAT:
|
||||
|
||||
PROTOCOLS = (
|
||||
'tcp',
|
||||
'udp',
|
||||
'icmp'
|
||||
)
|
||||
|
||||
def __init__(self,
|
||||
name,
|
||||
range_in,
|
||||
|
@ -648,17 +654,11 @@ class NAT:
|
|||
grp: The name of the group
|
||||
ports: The port range (str)
|
||||
"""
|
||||
for protocol in self.PROTOCOLS:
|
||||
CommandExec.run([
|
||||
*self.nft,
|
||||
"add rule ip nat {name}_nat ip saddr @{name}_nat_port_{grp} ip protocol tcp snat ip saddr map @{name}_nat_address : {ports}".format(
|
||||
name=self.name,
|
||||
grp=grp,
|
||||
ports=ports
|
||||
)
|
||||
])
|
||||
CommandExec.run([
|
||||
*self.nft,
|
||||
"add rule ip nat {name}_nat ip saddr @{name}_nat_port_{grp} ip protocol udp snat ip saddr map @{name}_nat_address : {ports}".format(
|
||||
"add rule ip nat {name}_nat ip saddr @{name}_nat_port_{grp} ip protocol {protocol} snat ip saddr map @{name}_nat_address : {ports}".format(
|
||||
protocol=protocol,
|
||||
name=self.name,
|
||||
grp=grp,
|
||||
ports=ports
|
||||
|
|
Loading…
Reference in a new issue