Linux iptables常用防火墙规则


iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

#允许本地回环接口(即运行本机访问本机)


iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT  

  #允许已建立的或相关连的通行


iptables -A OUTPUT -j ACCEPT        

#允许所有本机向外的访问


iptables -A INPUT -p tcp --dport 22 -j ACCEPT   

#允许访问22端口


iptables -A INPUT -p tcp --dport 80 -j ACCEPT   

#允许访问80端口


iptables -A INPUT -p tcp --dport 21 -j ACCEPT   

#允许ftp服务的21端口


iptables -A INPUT -p tcp --dport 20 -j ACCEPT   

#允许FTP服务的20端口


iptables -A INPUT -j reject      

#禁止其他未允许的规则访问


iptables -A FORWARD -j REJECT    

#禁止其他未允许的规则访问


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM