Firewalld添加规则POSTROUTING

时间:2019-07-08 08:49:42

标签: centos centos7 firewall iptables firewalld

当我想在firewalld中添加以下规则时:

firewall-cmd --direct --add-rule ipv4 nat POSTROUTING 0 -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to 10.8.0.0/24

我收到此错误:

Error: COMMAND_FAILED: '/usr/sbin/iptables-restore -w -n' failed: iptables-restore v1.4.21: Bad IP address "10.8.0.0/24"

Error occurred at line: 2
Try `iptables-restore -h' or 'iptables-restore --help' for more information.

1 个答案:

答案 0 :(得分:-1)

应该是:

def mainStuff():
    for a in aa:
        aName = aa[a].split('')[-1].split('-')[5]
        aName = replaceOne(aName)
        aName = replaceTwo(aName)

def replaceOne(aName: str) -> str:
    if aName.split('_')[1] == "android":
        aName = aName.replace('_android','Android')
    return aName

def replaceTwo(aName: str) -> str:
    if aName.split('_')[4:7] == "abc":
        aName = aName.replace('abc','Tom')
    return aName