查看端口:html
netstat -tunlp |grep 8080 查看8080 佔用linux
netstat -tunlp 用於查看全部的端口號的進程狀況vim
-----------------------------------------------------------------centos
因爲centos7默認是使用firewall做爲防火牆,下面介紹如何將系統的防火牆設置爲iptables。curl
#中止firewall
systemctl stop firewall.servicetcp
#禁止firewall開機啓動
systemctl disable firewall.service測試
#安裝iptables url
yum install iptables-services
查看開啓了哪些端口centos7
netstat -aptn
-----------------spa
查看防火牆狀態
service iptables status
# 中止防火牆
service iptables stop
# 啓動防火牆
service iptables start
# 重啓防火牆
service iptables restart
# 永久關閉防火牆
chkconfig iptables off
# 永久關閉後重啓
chkconfig iptables on
--------------------------------------
開啓80端口
vim /etc/sysconfig/iptables # 加入以下代碼 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
保存退出後重啓防火牆
service iptables restart
方法1
curl -l http://www.baidu.com
方法2
wget http://www.baidu.com