- 检查服务器是否安装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