# netTool **Repository Path**: bonn_admin/net-tool ## Basic Information - **Project Name**: netTool - **Description**: No description available - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-20 - **Last Updated**: 2026-01-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 跨平台TCP测试终端 netTool ## 开发初衷 在windows平台上有很多的TCP测试工具,非常方便。有一天,需要在linux测试一个端口是否正常打开时,没有找到合适的工具,搜索也没有发现。于是想开发一个测试工具。 ## 开发环境 vs2026 .net 10.0 打包 dotnet publish "nettool/nettool.csproj" -r linux-x64 --self-contained true -c Release -o "d:/mygitee/nettool/nettool/bin/release/net8.0/publish/linux-x64" /p:PublishSingleFile=true # linux下载 wget https://gitee.com/bonn_admin/net-tool/releases/download/v1.0.0/netTool && chmod +x netTool ## 命令示例 ```bash ./netTool ./netTool localIp=0.0.0.0 port=10003 ./netTool port=20001 ./netTool port=20001 echo=true ./netTool type=tcpServer port=20001 echo=true ./netTool type=tcpServer port=20001 respData=hello ./netTool type=tcpServer port=20001 respData=0x010203 ./netTool help bonn@bonnTest:~/桌面$ ./nettool localIp=0.0.0.0 port=8081 2026-01-26 16:27:25.375 版本: 1.0.1(20260126.03) 2026-01-26 16:27:25.469 Starting server... 2026-01-26 16:27:25.472 Server is listening at 0.0.0.0:8081 2026-01-26 16:27:28.871 192.168.0.225:6112 Client connected 2026-01-26 16:27:31.980 192.168.0.225:6112↑ Received: 49 20 61 6D 20 43 6C 69 65 6E 74 20 54 65 73 74 20[I am Client Test ] 2026-01-26 16:27:33.631 192.168.0.225:6112↑ Received: 49 20 61 6D 20 43 6C 69 65 6E 74 20 54 65 73 74 20[I am Client Test ] 2026-01-26 16:27:34.477 192.168.0.225:6112↑ Received: 49 20 61 6D 20 43 6C 69 65 6E 74 20 54 65 73 74 20[I am Client Test ] bonn@bonnTest:~/桌面$ ./nettool localIp=0.0.0.0 port=8081 echo=true 2026-01-26 16:31:36.797 版本: 1.0.1(20260126.03) 2026-01-26 16:31:36.885 启用回声模式 2026-01-26 16:31:36.893 Starting server... 2026-01-26 16:31:36.897 Server is listening at 0.0.0.0:8081 2026-01-26 16:31:41.684 192.168.0.225:13190 Client connected 2026-01-26 16:31:45.223 192.168.0.225:13190↑ Received: 49 20 61 6D 20 43 6C 69 65 6E 74 20 54 65 73 74 20[I am Client Test ] 2026-01-26 16:31:45.223 192.168.0.225:13190↓ Response: 49 20 61 6D 20 43 6C 69 65 6E 74 20 54 65 73 74 20 2026-01-26 16:31:48.128 192.168.0.225:13190↑ Received: 49 20 61 6D 20 43 6C 69 65 6E 74 20 54 65 73 74 20[I am Client Test ] 2026-01-26 16:31:48.128 192.168.0.225:13190↓ Response: 49 20 61 6D 20 43 6C 69 65 6E 74 20 54 65 73 74 20 2026-01-26 16:31:57.182 192.168.0.225:13197 Client connected 2026-01-26 16:31:59.790 192.168.0.225:13197↑ Received: 57 65 6C 63 6F 6D 65 20 74 6F 20 4E 65 74 41 73 73 69 73 74[Welcome to NetAssist] 2026-01-26 16:31:59.790 192.168.0.225:13197↓ Response: 57 65 6C 63 6F 6D 65 20 74 6F 20 4E 65 74 41 73 73 69 73 74 ./nettool localIp=0.0.0.0 port=8081 echo=true respData=hello ``` # 其他工具示例 ## socat 如果没有安装,则先安装 ```bash sudo apt install socat # Debian/Ubuntu sudo yum install socat # CentOS/RHEL ``` 侦听8080端口 ```bash bonn@bonnTest:~/桌面$ socat TCP-LISTEN:8080,fork STDOUT 2026/01/26 15:27:39 socat[3048] W address is opened in read-write mode but only supports write-only I am Client TestI am Client Test ``` socat - tcp-listen:1234,fork #STDIO TCP 服务端监听1234端口 socat - tcp:127.0.0.1:1234 #STDIO TCP 客户端连接1234端口 socat - udp4-listen:1234,bind=192.168.56.20,fork #STDIO UDP 服务端仅监听192.168.56.20接口的1234端口 socat - udp4:192.168.56.20:1234 #STDIO UDP 客户端连接1234端口 socat可以创建虚拟串口 创建两个可以相互通信的 Linux 虚拟串口 socat -d -d PTY PTY ## nc ```bash bonn@bonnTest:~/桌面$ nc -l -p 8080 I am Client Test I am Client Test ```