Linux 开放指定端口

1. 开放Linux的8080端口

添加-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

[root@Hm311~]# vi /etc/sysconfig/iptables

# Generated by iptables-save v1.4.7 on Wed Mar 22 17:51:24 2017
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0] 
-A INPUT -m state --state RELATED,ESTABLISHED -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 ACCEPT  
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT  
-A INPUT -j REJECT --reject-with icmp-host-prohibited 

-A FORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

2.修改完保存退出,重启网卡服务

[root@Hm311~]# service iptables restart

3. 查看端口开放信息

[root@iZbp1h0hzrtzkjfh778xnmZ ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:22
2    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8080

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

猜你喜欢

转载自blog.csdn.net/yk10010/article/details/81296551
今日推荐