Netstat & telnet

Netstat

查看当前哪些端口在监听:netstat -ltnp

l – tells netstat to only show listening sockets.
t – tells it to display tcp connections.
n – instructs it show numerical addresses.
p – enables showing of the process ID and the process name.
grep -w – shows matching of exact string (:80).

$ netstat -ltnp|head -10
(No info could be read for "-p": geteuid()=1004 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      -  
...

注意:如果看不到PID是因为权限不够,换成root可以看到全部的PID.

查看端口占用:netstat -ano|grep 80

查看所有的TCP连接端口:netstat -an -p

Label: 监听端口网络端口查看端口网络检测网络请求状态TCP连接状态

telnet(Telnet)

The telnet command is used for interactive communication with another host using the TELNET protocol.

example

$ telnet 192.168.1.30 1521
Trying 192.168.1.30...
Connected to 192.168.85.55.
Escape character is '^]'.

你可能感兴趣的:(Netstat & telnet)