Linux下利用shell简单调试udp和tcp
背景
Linux环境下,有时候需要简单地进行下udp和tcp的测试,又不想去写C之类的代码,可以尝试下用Python或者直接用Shell来处理,简单方便,高效快捷。这里主要讲讲使用Shell的方式。

服务端主要使用 nc (netcat) 。
客户端主要使用/dev/tcp、/dev/udp。
nc: — arbitrary TCP and UDP connections and listens
The nc (or netcat) utility is used for just about anything under the sun
involving TCP, UDP, or UNIX-domain sockets. It can open TCP connections,
send UDP packets, listen on arbitrary TCP and UDP ports, do port scan‐
ning, and deal with both IPv4 and IPv6.

/dev/(tcp|udp)
虽然:/dev/(tcp|udp) 看起来很像一个文件系统中的文件,并且位于 /dev 这个设备文件夹下
但是:这个文件并不存在,而且并不是一个设备文件。
是一个 bash 的 一个特性。可以看官方说明:https://www.gnu.org/software/bash/manual/bash.html

/dev/(tcp|udp)/host/port

。。。。。。

更多请关注:

Linux下利用shell简单调试udp和tcp_Shell


作者: Shell