Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux CentOS 7,DNAT怎么了?_Linux_Centos_Firewall_Iptables - Fatal编程技术网

Linux CentOS 7,DNAT怎么了?

Linux CentOS 7,DNAT怎么了?,linux,centos,firewall,iptables,Linux,Centos,Firewall,Iptables,我正在CentOS 7上做一些防火墙工作。我的最终目标是从本质上使服务器的内部ip地址与分配给它的浮动ip地址相同。我禁用了firewalld并安装了iptables服务 /etc/redhat发布 CentOS Linux release 7.2.1511 (Core) iptables v1.4.21 运行此脚本时,我得到 iptables v1.4.21:未知选项“SNAT” 以及未知选项“DNAT” 我的剧本是 #!/bin/bash PRIVIP="107.170.40.128" #

我正在CentOS 7上做一些防火墙工作。我的最终目标是从本质上使服务器的内部ip地址与分配给它的浮动ip地址相同。我禁用了firewalld并安装了iptables服务

/etc/redhat发布

CentOS Linux release 7.2.1511 (Core)
iptables v1.4.21

运行此脚本时,我得到

iptables v1.4.21:未知选项“SNAT” 以及未知选项“DNAT”

我的剧本是

#!/bin/bash
PRIVIP="107.170.40.128" # e.g., assuming this is the private IP address
FLOATIP="104.196.55.167" # e.g. assuming this is the floating IP address
echo "iptables"
echo "/sbin/iptables -t nat -A PREROUTING -d ${PRIVIP}/32 -j DNAT -–to-destination ${FLOATIP}"
/sbin/iptables -t nat -A PREROUTING -d ${PRIVIP}/32 -j DNAT -–to-destination ${FLOATIP}
echo "/sbin/iptables -t nat -A POSTROUTING -s ${FLOATIP}/32 -j SNAT -–to-source ${PRIVIP}"
/sbin/iptables -t nat -A POSTROUTING -s ${FLOATIP}/32 -j SNAT -–to-source ${PRIVIP}
echo "arp"
/sbin/arp -i eth0 -Ds ${PRIVIP} eth0 netmask 255.255.255.255 pub
/sbin/arp -an
echo "sleep"
sleep 10
systemctl restart network

Centos 6中的DNAT和SNAT选项发生了什么变化

我认为您应该分别用
-目的地
-源
替换
-目的地
-源
。/sbin/iptables-t nat-A postfrouting-s 104.196.55.167-j DNAT-source 107.170.40.128 iptables v1.4.21:未知选项“DNAT”Fwiw,DNAT在我的CentOS 7系统上运行良好。如果你在更合适的地方问这个问题,比如或,你可能会得到更好的答案。StackOverflow用于编程相关问题。我认为您应该分别用
--目的地
--源
替换
--目的地
--源
。/sbin/iptables-t nat-A后路由-s 104.196.55.167-j DNAT--source 107.170.40.128 iptables v1.4.21:未知选项“DNAT”Fwiw,DNAT在我的CentOS 7系统上运行良好。如果你在更合适的地方问这个问题,比如或,你可能会得到更好的答案。StackOverflow用于编程相关问题。