CentOS使用iptables开放3000端口

关闭firewall

systemctl stop firewalld.service

禁止firewall开机启动

systemctl disable firewalld.service

设置iptables

yum -y install iptables-services

查看iptables对外开放了哪些端口

iptables -L -n

修改iptables配置

vi /etc/sysconfig/iptables

添加3000端口

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10051 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10050 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 4505 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 4506 -j ACCEPT
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-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 45685 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
~       

重启iptables使配置生效

systemctl restart iptables.service

设置iptables开机启动

systemctl enable iptables.service

 

posted @ 2019-01-30 11:21  ycyzharry  阅读(5113)  评论(0编辑  收藏  举报