这些天都在linux系统上安装SNMP协议,该协议默认开启UDP协议的161端口,记录一下测试过程。
我们知道socket端口可以通过telnet x.x.x.x port来测试主机与目标端口的网络是否通畅。那么udp端口如何测试呢?
UDP端口连接测试:
1.测试目标端口是否正常(前提是目标主机上启动了服务端口,且本机与服务端网络通畅的情况): nc -vuz x.x.x.x xxxx
[root@localhost etc]# nc -vuz 192.168.3.146 3306
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.3.146:3306.
Ncat: Connection refused.
[root@localhost etc]# nc -vz 192.168.3.146 3306
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.3.146:3306.
Ncat: 0 bytes sent, 0 bytes received in 0.02 seconds.
2.向UDP端口发送消息: nc -vu x.x.x.x xxxx
[root@localhost etc]# nc -vu 192.168.3.146 161
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.3.146:161.
affgfdfdg
fagfagdgfgfg
hfakjflajflasjflsajflafjl
ajlfjoejrejfojflksjflksjflskjflkajflsfk
3.通过抓包命令进行抓包,接收UDP端口抓包: tcpdump -i eth0 -s 0 port 161
[root@node01 Packages]# tcpdump -i eth0 -s 0 port 161
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
13:48:39.133996 IP 192.168.0.161.51223 > 192.168.3.146.snmp: [len11<asnlen97]
13:49:12.816703 IP 192.168.0.161.51223 > 192.168.3.146.snmp: [len24<asnlen102]
13:50:08.810687 IP 192.168.0.161.51223 > 192.168.3.146.snmp: [len38<asnlen106]