在 Linux 上用 socat 进行网络环境测试 用 lsof netstat ss 检测 TCP 端口占用
在搭梯子的过程中,有可能会遇到奇怪的事情。比如,搭在
参考
https://thiscute.world/posts/socat-netcat/
https://www.runoob.com/w3cnote/linux-check-port-usage.html
安装
apt install -y socat
网络环境测试
socat tcp6-listen:端口 -
socat tcp6-listen:9527 -
#注意末尾有个 空格 减号socat tcp4-listen:9527 -
socat tcp-connect:IP地址: 端口 -
socat tcp-connect:[2607:f130:0:ea:ff:ff:ff97:3471]:9527 -
socat tcp-connect:170.178.237.252:9527 -
socat tcp-connect:localhost:9527 -
检查端口占用
lsof -i:9527
netstat -tunlp | grep 9527
更新
要使用 netstat, 需要安装 net-tools
apt install -y net-tools
可以换用 ss, Debian
ss -tunlp | grep 进程名或者端口号
ss -tunlp | grep caddy
ss -tunlp | grep 2019
评论
发表评论