常用的组合:
- an 所有的连接和端口
- tuln 查看正在监听TCP(t)和UDP(u)的端口
- rn 查看网关 route -n
组合命令,查看系统中正在监听的端口数量:
netstat -tuln | grep LISTEN | wc -l
[root@localhost Tools]# netstat -tuln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
udp 0 0 0.0.0.0:5353 0.0.0.0:*
udp 0 0 0.0.0.0:48437 0.0.0.0:*
udp 0 0 127.0.0.1:323 0.0.0.0:*
udp 0 0 0.0.0.0:54268 0.0.0.0:*
udp 0 0 192.168.122.1:53 0.0.0.0:*
udp 0 0 0.0.0.0:67 0.0.0.0:*
udp 0 0 0.0.0.0:68 0.0.0.0:*
udp6 0 0 ::1:323 :::*
udp6 0 0 :::20514 :::*
翻译域名对应的ip和DNS
查看百度的ip,其中Server表示当前的DNS:
[root@localhost Tools]# nslookup www.baidu.com
Server: 192.168.226.2
Address: 192.168.226.2#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 115.239.211.112
判断网络状况
- -c 发送数据包的次数
[root@localhost Tools]# ping -c 3 www.baidu.com
PING www.a.shifen.com (115.239.210.27) 56(84) bytes of data.
64 bytes from 115.239.210.27 (115.239.210.27): icmp_seq=1 ttl=128 time=28.0 ms
64 bytes from 115.239.210.27 (115.239.210.27): icmp_seq=2 ttl=128 time=19.8 ms
64 bytes from 115.239.210.27 (115.239.210.27): icmp_seq=3 ttl=128 time=28.4 ms
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 19.891/25.488/28.485/3.963 ms
telnet ip port
明文传递数据,不安全,已弃用。现在可以用来探测对方的端口是否开启
windows也有telnet协议,只不过,默认是关闭的,使用telnet探测虚拟机的22端口,会进入一个空白的画面。虽然不能控制虚拟机,但是可以说明22端口是可用的。如果端口不可用会提示链接失败。
telnet 192.168.226.128 22
traceroute ip(域名)
路由跟踪命令
- -n 使用ip,速度更快
- -q 每次发送的数据包数量,默认是3
- -m 设置跳数,默认是30
win中使用tracert命令达到相同的效果
抓包工具
port 指定监听的端口
tcpdump -i ens33 -nn -X port 21 检查21端口的数据包
[root@localhost network-scripts]# tcpdump -i ens33 -nn -X
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens33, link-type EN10MB (Ethernet), capture size 65535 bytes
11:44:39.513385 IP 192.168.42.1.55904 > 239.255.255.250.1900: UDP, length 174
0x0000: 4500 00ca 1342 0000 0111 cb3d c0a8 2a01 E....B.....=..*.
0x0010: efff fffa da60 076c 00b6 3d68 4d2d 5345 .....`.l..=hM-SE
0x0020: 4152 4348 202a 2048 5454 502f 312e 310d ARCH.*.HTTP/1.1.
0x0030: 0a48 4f53 543a 2032 3339 2e32 3535 2e32 .HOST:.239.255.2
0x0040: 3535 2e32 3530 3a31 3930 300d 0a4d 414e 55.250:1900..MAN
0x0050: 3a20 2273 7364 703a 6469 7363 6f76 6572 :."ssdp:discover
0x0060: 220d 0a4d 583a 2031 0d0a 5354 3a20 7572 "..MX:.1..ST:.ur
0x0070: 6e3a 6469 616c 2d6d 756c 7469 7363 7265 n:dial-multiscre
0x0080: 656e 2d6f 7267 3a73 6572 7669 6365 3a64 en-org:service:d
0x0090: 6961 6c3a 310d 0a55 5345 522d 4147 454e ial:1..USER-AGEN
0x00a0: 543a 2047 6f6f 676c 6520 4368 726f 6d65 T:.Google.Chrome
0x00b0: 2f35 392e 302e 3330 3731 2e31 3034 2057 /59.0.3071.104.W
0x00c0: 696e 646f 7773 0d0a 0d0a indows....
11:44:40.514356 IP 192.168.42.1.55904 > 239.255.255.250.1900: UDP, length 174
0x0000: 4500 00ca 1343 0000 0111 cb3c c0a8 2a01 E....C.....<..*.
0x0010: efff fffa da60 076c 00b6 3d68 4d2d 5345 .....`.l..=hM-SE
0x0020: 4152 4348 202a 2048 5454 502f 312e 310d ARCH.*.HTTP/1.1.
0x0030: 0a48 4f53 543a 2032 3339 2e32 3535 2e32 .HOST:.239.255.2
0x0040: 3535 2e32 3530 3a31 3930 300d 0a4d 414e 55.250:1900..MAN
0x0050: 3a20 2273 7364 703a 6469 7363 6f76 6572 :."ssdp:discover
0x0060: 220d 0a4d 583a 2031 0d0a 5354 3a20 7572 "..MX:.1..ST:.ur
0x0070: 6e3a 6469 616c 2d6d 756c 7469 7363 7265 n:dial-multiscre
0x0080: 656e 2d6f 7267 3a73 6572 7669 6365 3a64 en-org:service:d
0x0090: 6961 6c3a 310d 0a55 5345 522d 4147 454e ial:1..USER-AGEN
0x00a0: 543a 2047 6f6f 676c 6520 4368 726f 6d65 T:.Google.Chrome
0x00b0: 2f35 392e 302e 3330 3731 2e31 3034 2057 /59.0.3071.104.W
0x00c0: 696e 646f 7773 0d0a 0d0a indows....
11:44:41.514257 IP 192.168.42.1.55904 > 239.255.255.250.1900: UDP, length 174
0x0000: 4500 00ca 1344 0000 0111 cb3b c0a8 2a01 E....D.....;..*.
0x0010: efff fffa da60 076c 00b6 3d68 4d2d 5345 .....`.l..=hM-SE
0x0020: 4152 4348 202a 2048 5454 502f 312e 310d ARCH.*.HTTP/1.1.
0x0030: 0a48 4f53 543a 2032 3339 2e32 3535 2e32 .HOST:.239.255.2
0x0040: 3535 2e32 3530 3a31 3930 300d 0a4d 414e 55.250:1900..MAN
0x0050: 3a20 2273 7364 703a 6469 7363 6f76 6572 :."ssdp:discover
0x0060: 220d 0a4d 583a 2031 0d0a 5354 3a20 7572 "..MX:.1..ST:.ur
0x0070: 6e3a 6469 616c 2d6d 756c 7469 7363 7265 n:dial-multiscre
0x0080: 656e 2d6f 7267 3a73 6572 7669 6365 3a64 en-org:service:d
0x0090: 6961 6c3a 310d 0a55 5345 522d 4147 454e ial:1..USER-AGEN
0x00a0: 543a 2047 6f6f 676c 6520 4368 726f 6d65 T:.Google.Chrome
0x00b0: 2f35 392e 302e 3330 3731 2e31 3034 2057 /59.0.3071.104.W
0x00c0: 696e 646f 7773 0d0a 0d0a indows....
11:44:42.514598 IP 192.168.42.1.55904 > 239.255.255.250.1900: UDP, length 174
0x0000: 4500 00ca 1345 0000 0111 cb3a c0a8 2a01 E....E.....:..*.
0x0010: efff fffa da60 076c 00b6 3d68 4d2d 5345 .....`.l..=hM-SE
0x0020: 4152 4348 202a 2048 5454 502f 312e 310d ARCH.*.HTTP/1.1.
0x0030: 0a48 4f53 543a 2032 3339 2e32 3535 2e32 .HOST:.239.255.2
0x0040: 3535 2e32 3530 3a31 3930 300d 0a4d 414e 55.250:1900..MAN
0x0050: 3a20 2273 7364 703a 6469 7363 6f76 6572 :."ssdp:discover
0x0060: 220d 0a4d 583a 2031 0d0a 5354 3a20 7572 "..MX:.1..ST:.ur
0x0070: 6e3a 6469 616c 2d6d 756c 7469 7363 7265 n:dial-multiscre
0x0080: 656e 2d6f 7267 3a73 6572 7669 6365 3a64 en-org:service:d
0x0090: 6961 6c3a 310d 0a55 5345 522d 4147 454e ial:1..USER-AGEN
0x00a0: 543a 2047 6f6f 676c 6520 4368 726f 6d65 T:.Google.Chrome
0x00b0: 2f35 392e 302e 3330 3731 2e31 3034 2057 /59.0.3071.104.W
0x00c0: 696e 646f 7773 0d0a 0d0a indows....
^C
4 packets captured
4 packets received by filter
0 packets dropped by kernel
ftp是明文传递,可以直接解析ftp包中的用户名和密码,因此telnet和ftp不是绝对安全的