Mac OS X view network port conditions

Source: Internet
Author: User
Tags fpm

To see if the port is open

Use netstatCommand
a. `netstat -nat | grep <端口号>`  , 如命令 `netstat -nat | grep 3306`b. `netstat -nat |grep LISTEN`
Use lsofCommand
# Yongfu-proAt yongfu-pro.localIn ~ [22:39:32]$ lsof-n-p-i tcp-s tcp:listencommand PID USER FD TYPE DEVICE size/off NODE namephp-fpm387 Yongfu-pro 6u IPv40x6d7f5d3c3a6156790t0 TCP127.0.0.1:9000 (LISTEN) Dropbox413 Yongfu-pro 26u IPv40x6d7f5d3c445e2c090t0 TCP *:17500 (LISTEN) php-fpm418 Yongfu-pro 0u IPv40x6d7f5d3c3a6156790t0 TCP127.0.0.1:9000 (LISTEN) php-fpm419 Yongfu-pro 0u IPv40x6d7f5d3c3a6156790t0 TCP 127.0. 0. 1:9000 (LISTEN) php-fpm 420 yongfu-pro 0u IPv4 0x6d7f5d3c3a615679 0t0 TCP 127.0. 0. 1:9000 (LISTEN) stunnel 586 yongfu-pro 9u IPv4 0x6d7f5d3c439ff679 0t0 TCP  127.0. 0. 1:1997 (LISTEN) lsof command can list all current network conditions, this command is interpreted as follows:-n means that the host is displayed as an IP address-p means that the port is displayed as a number, by default the port name-I More meaningful, specific man lsof, mainly used to filter the output of lsof-s and-I with use, for filtering output          
Use telnetCommand
检查本机的3306端口是否打开, 如下telnet 127.0.0.1 3306 若该端口没有打开,则会自动退出,并显示如下内容:Trying 127.0.0.1...telnet: connect to address 127.0.0.1: Connection refusedtelnet: Unable to connect to remote host

If the port is open, it will remain connected.


Exit Method: Ctrl +] then CTRL + C

Or: Ctrl + D and enter key

Use ncCommand
# yongfu at yf-mac.local in ~ [9:33:14]$ nc  -w 10 -n -z 127.0.0.1 1990-1999Connection to 127.0.0.1 port 1997 [tcp/*] succeeded!Connection to 127.0.0.1 port 1998 [tcp/*] succeeded!-w 10  表示等待连接时间为10秒-n 尽量将端口号名称转换为端口号数字-z 对需要检查的端口没有输入输出,用于端口扫描模式127.0.0.1 需要检查的ip地址1990-1999 可以是一个端口,也可以是一段端口 返回结果为开放的端口, 如本例中的 1997 和 1998 端口
Use 网络实用工具

Network Utility is Apple's own network analysis tool
Before 10.8, located in launchpad --> 其他--> 网络实用工具
The app is hidden after 10.9, but can be spotlight searched 网络实用工具 or 最左上角的苹果标志 --> 关于本机 -->点按‘系统报告‘ --> 标题栏的‘窗口‘ --> 网络实用工具 --> 点按‘端口扫描‘
Spotlight Search

Or

In the network using the tool interface, select the ' Port Scan ' tab, enter an IP address to scan the open interface.
Here we enter 127.0.0.1 to view the port opening of this machine.

In the case of command line, this method is highly deprecated because the graphical tool is scanned sequentially from 0 to 65535 in the order of the ports, too slow. Recommended command line mode.

Transfer from http://my.oschina.net/foreverich/blog/402252

Mac OS X view network port conditions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.