修改iptables后重启返回错误

时间:2023-03-08 15:53:52

在防火墙添加规则后我是这样改的vi /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT

重启:/etc/init.d/iptables restart

返回值:Error occurred at line: 16
Try `iptables-restore -h‘ or ‘iptables-restore --help‘ for more information.
[FAILED]

找到解决方法:

/sbin/iptables -I INPUT -p tcp --dport 21 -j ACCEPT

/etc/rc.d/init.d/iptables save

/etc/init.d/iptables restart

重启成功:iptables: Setting chains to policy ACCEPT: filter [  OK  ]
iptables: Flushing firewall rules: [  OK  ]
iptables: Unloading modules: [  OK  ]
iptables: Applying firewall rules: [  OK  ]