linux关闭端口命令_linux 网络检测常用命令(tcp/udp 端口检测)

1,tcp 端口检测

telnet ip port

[dev@kf-dev-node-004 ~]$ telnet 10.32.2.231 5060

失败:

Trying 10.32.2.231…

telnet: connect to address 10.32.2.231: Connection refused

成功:

[dev@kf-dev-node-004 ~]$ telnet 10.32.2.232 5080

Trying 10.32.2.232…

Connected to 10.32.2.232.

2,udp 端口检测

nc -vuz 10.32.2.231 5060

如果没有请自行安装

sudo yum install nc

a机器上运行:

nc -ul 1080

或:

netcat -ul -p 1080

#使用udp模式监听1080 端口

b机器上运行:

nc -u x.x.x.x 1080

或:

netcat -u x.x.x.x 1080

#使用udp模式向该ip的1080端口发送信息。

失败的表现为:

 nc -vuz x.x.x.x 16385

Ncat: Version 7.50 ( https://nmap.org/ncat )

Ncat: Connected to x.x.x.x:16385.

Ncat: Connection refused.

3,tcpdump发送抓包检测

sudo tcpdump -vvv -X udp port 6080

从另一个机器发包

echo “hello” | socat - udp4-datagram:10.32.2.231:5080

这边可以收到,证明没有问题:

sudo tcpdump -vvv -X udp port 5080

tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes

19:06:34.710707 IP (tos 0x0, ttl 64, id 52039, offset 0, flags [DF], proto UDP (17), length 40)

10.32.2.232.49090 > iZbp1c2a8ike46vqst3z81Z.onscreen: [udp sum ok] UDP, length 12

0x0000: 4500 0028 cb47 4000 4011 556f 0a20 02e8 E…(.G@.@.Uo…

0x0010: 0a20 02e7 bfc2 13d8 0014 41cc e280 9c68 …A…h

0x0020: 656c 6c6f e280 9d0a ello…

1b1d8b0df4a5bef2dab6c08cf524931d.png
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值