- 检查服务器是否安装iptables
$ service iptables status
Redirecting to /bin/systemctl status iptables.service
Unit iptables.service could not be found.
若返回以上信息,则说明未安装iptables
2. 安装iptables
$ yum install -y iptables
- 开放zbus的15555端口
$ vi /etc/sysconfig/iptables
进入编辑页面,在指定位置新增以下配置
-A INPUT -m state --state NEW -m tcp -p tcp --dport 15555 -j ACCEPT
这句要放在 -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT 后面
修改后的整体为下面所示
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
#ip白名单
-N whitelist
-A INPUT -s xx.xx.xx.xx -j ACCEPT
-A INPUT -s xx.xx.xx.xx -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j whitelist
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 15555 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
- 修改完保存退出,重启网卡服务
$ service iptables restart
- 查看端口开放信息
$ service iptables status
本文介绍了如何检查并确认iptables是否安装,如果未安装则通过yum进行安装。接着展示了如何编辑iptables配置文件,打开15555端口,并将规则放置在指定位置。最后,保存配置并重启iptables服务以应用改动,确保端口开放。
621

被折叠的 条评论
为什么被折叠?



