一些好用的命令

今天在解决一个问题时,需要测下某机器的指定端口是否能正常接收数据,忽然发现想不起来命令叫啥(就是nc),看来还是要做好记录。考虑到后续可能还会添加新的命令,还要方便查阅和分享,索性就记到这里吧。

这里不打算记录太详细的使用方法,等需要的时候再查也不迟,Too long, didn’t read

网络相关

nc

arbitrary TCP and UDP connections and listens

针对 TCP 或 UDP 连接做一些奇奇怪怪的操作,甚至可以作为一个简单的代理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Netcat is a versatile utility for working with TCP or UDP data.
More information: <https://nmap.org/ncat>.

- Listen on a specified port and print any data received:
nc -l port

- Connect to a certain port:
nc ip_address port

- Set a timeout:
nc -w timeout_in_seconds ipaddress port

- Keep the server up after the client detaches:
nc -k -l port

- Keep the client up even after EOF:
nc -q timeout ip_address

- Scan the open ports of a specified host:
nc -v -z ip_address port

- Act as proxy and forward data from a local TCP port to the given remote host:
nc -l local_port | nc hostname remote_port