我使用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
但这在重启后就不存在了。
所以我怎么能打开端口,使它幸存重启?
当前回答
如果您在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]
其他回答
如果您在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]
如果你熟悉centos 6或更早版本的iptables服务,你仍然可以通过手动安装使用iptables服务:
步骤1 => install epel repo
Yum安装epel-release
步骤2 => install iptables service . sh
Yum安装iptables-services
步骤3 =>停止防火墙服务
Systemctl停止防火墙
步骤4 =>启动时禁用防火墙服务
Systemctl禁用防火墙
步骤5 =>启动iptables服务
Systemctl启动iptables
步骤6 => enable iptables on startup
Systemctl启用iptables
最后,您现在可以在/etc/sysconfig/iptables编辑您的iptables配置。
所以->编辑规则->重新加载/重新启动。
做像更老的centos与相同的功能像防火墙。
神之神的回答是正确的,但是 知道你可以使用以下方法也是很有用的:
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
你好在Centos 7 firewall-cmd。 是的,如果你用 Firewall-cmd——zone=public——add-port=2888/tcp .使用实例 但如果你重新加载防火墙 firewall-cmd——重载
你的配置不会被保存
你需要添加key
Firewall-cmd——permanent——zone=public——add-port=2888/tcp