我使用CentOS 7,我必须确保端口2888和3888是开放的。
我读了这篇文章,但这并不管用,因为在CentOS 7操作系统上没有iptables保存命令。
有人告诉我上面的URL对CentOS 7无效。我应该跟着这个走。 但是这篇文章对我来说并不清楚我需要执行什么命令。
我还发现
firewall-cmd --zone=public --add-port=2888/tcp
但这在重启后就不存在了。
所以我怎么能打开端口,使它幸存重启?
我使用CentOS 7,我必须确保端口2888和3888是开放的。
我读了这篇文章,但这并不管用,因为在CentOS 7操作系统上没有iptables保存命令。
有人告诉我上面的URL对CentOS 7无效。我应该跟着这个走。 但是这篇文章对我来说并不清楚我需要执行什么命令。
我还发现
firewall-cmd --zone=public --add-port=2888/tcp
但这在重启后就不存在了。
所以我怎么能打开端口,使它幸存重启?
当前回答
神之神的回答是正确的,但是 知道你可以使用以下方法也是很有用的:
firewall-cmd --permanent --zone=public --add-port=2888/tcp
但如果是一个已知的服务,你可以使用:
firewall-cmd --permanent --zone=public --add-service=http
然后重新加载防火墙
firewall-cmd --reload
[回答修改以反映Martin Peter的评论,原来的回答有-永久在命令行结束]
其他回答
防火墙对于iptables老手来说有点不直观。对于那些喜欢使用iptables驱动的防火墙,并在易于配置的树中使用类似iptables的语法的人,可以尝试用fwtree替换firewall: https://www.linuxglobal.com/fwtree-flexible-linux-tree-based-firewall/ 然后做以下事情:
echo '-p tcp --dport 80 -m conntrack --cstate NEW -j ACCEPT' > /etc/fwtree.d/filter/INPUT/80-allow.rule
systemctl reload fwtree
Fedora是通过iptables实现的
sudo iptables -I INPUT -p tcp --dport 3030 -j ACCEPT
sudo service iptables save
似乎有效
神之神的回答是正确的,但是 知道你可以使用以下方法也是很有用的:
firewall-cmd --permanent --zone=public --add-port=2888/tcp
但如果是一个已知的服务,你可以使用:
firewall-cmd --permanent --zone=public --add-service=http
然后重新加载防火墙
firewall-cmd --reload
[回答修改以反映Martin Peter的评论,原来的回答有-永久在命令行结束]
你好在Centos 7 firewall-cmd。 是的,如果你用 Firewall-cmd——zone=public——add-port=2888/tcp .使用实例 但如果你重新加载防火墙 firewall-cmd——重载
你的配置不会被保存
你需要添加key
Firewall-cmd——permanent——zone=public——add-port=2888/tcp
如果您在Centos 7防火墙中允许多个端口,那么我们可以使用以下命令。
#firewall-cmd --add-port={port number/tcp,port number/tcp} --permanent
#firewall-cmd --reload
And check the Port opened or not after reloading the firewall.
#firewall-cmd --list-port
For other configuration [Linuxwindo.com][1]