检测端口是否开启

 

sh-4.1# nc -w 5 baidu.com 80 && echo ok
ok
sh-4.1# nc -w 5 baidu.com 81
sh-4.1# echo $?
1
sh-4.1# nc -w 5 baidu.com 80
sh-4.1# echo $? #返回上面命
0

telnet 查看端口是否开启:

sh-4.1# telnet baidu.com 84
Trying 111.13.101.208...
telnet: connect to address 111.13.101.208: Connection timed out

百度开了80,而并没开84所以,连84端口失败

sh-4.1# telnet baidu.com 80
Trying 123.125.114.144...
Connected to baidu.com.
Escape character is '^]'.

 

posted @ 2016-11-21 12:54  bass  阅读(243)  评论(0编辑  收藏  举报