linux防火墙开放端口


/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT #开启80端口 

/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT #开启22端口 

/etc/rc.d/init.d/iptables save #保存配置 
/etc/rc.d/init.d/iptables restart #重启服务 
查看已开放端口 
/etc/init.d/iptables status 
结果如下 
Table: filter 
Chain INPUT (policy ACCEPT) 
num target prot opt source destination 
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 
3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 
 
 

你可以使用 lsof 命令来查看某一端口是否开放。查看端口可以这样来使用,我就以80端口为例: 
lsof -i:80 
如果有显示说明已经开放了,如果没有显示说明没有开放。


免责声明!

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



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