Linux(CentOS6.5) 開放端口,配置防火牆


1. 打開配置文件

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

 

2. 正確的配置文件

# 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] -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 ACCEPT -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT -A INPUT -j REJECT –reject-with icmp-host-prohibited -A FORWARD -j REJECT –reject-with icmp-host-prohibited COMMIT
-A INPUT -m state –state NEW -m tcp -p tcp –dport * -j AC

 

 

 

 

 

 

3. 新開啟的端口 一定要在22端口的后面寫

重啟防火牆  使配置生效

[root@localhost ~]# /etc/init.d/iptables restart



查看開放的端口
[root@localhost ~]# /etc/init.d/iptables status

 

 

 關閉防火牆

[root@localhost ~]# /etc/init.d/iptables stop

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM