打开第二台虚拟机(带图形界面的虚拟机)
使用浏览器访问一些网站,然后统计这些连接处于time-wait的数量
[root@test-server sysctl.d]# netstat -an | grep TIME_WAIT | wc -l
14
打开两台Linux虚拟机,然后测试它们之间的TCP性能和UDP性能,并将结果记录下来
## 虚拟机01
[root@test-server ~]# iperf -c 192.168.115.128 -p 5001 -i 1 -t 10
------------------------------------------------------------
Client connecting to 192.168.115.128, TCP port 5001
TCP window size: 2.50 MByte (default)
------------------------------------------------------------
[ 3] local 192.168.115.128 port 58162 connected with 192.168.115.128 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 4.87 MBytes 40.9 Mbits/sec
[ 3] 1.0- 2.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 2.0- 3.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 3.0- 4.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 4.0- 5.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 5.0- 6.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 6.0- 7.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 7.0- 8.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 8.0- 9.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 9.0-10.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 0.0-10.3 sec 4.87 MBytes 3.97 Mbits/sec
[root@test-server ~]# iperf -c 192.168.115.128 -p 5001 -i 1 -t 10 -u
------------------------------------------------------------
Client connecting to 192.168.115.128, UDP port 5001
Sending 1470 byte datagrams, IPG target: 11215.21 us (kalman adjust)
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.115.128 port 39178 connected with 192.168.115.128 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 129 KBytes 1.06 Mbits/sec
[ 3] 1.0- 2.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 2.0- 3.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 3.0- 4.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 4.0- 5.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 5.0- 6.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 6.0- 7.0 sec 129 KBytes 1.06 Mbits/sec
[ 3] 7.0- 8.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 8.0- 9.0 sec 128 KBytes 1.05 Mbits/sec
read failed: Connection refused
[ 3] WARNING: did not receive ack of last datagram after 1 tries.
[ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec
[ 3] Sent 891 datagrams
## 虚拟机02
[root@wei ~]# iperf -c 192.168.115.130 -p 5001 -i 1 -t 10
------------------------------------------------------------
Client connecting to 192.168.115.130, TCP port 5001
TCP window size: 2.50 MByte (default)
------------------------------------------------------------
[ 3] local 192.168.115.130 port 38738 connected with 192.168.115.130 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 4.87 MBytes 40.9 Mbits/sec
[ 3] 1.0- 2.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 2.0- 3.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 3.0- 4.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 4.0- 5.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 5.0- 6.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 6.0- 7.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 7.0- 8.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 8.0- 9.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 9.0-10.0 sec 0.00 Bytes 0.00 bits/sec
[ 3] 0.0-10.0 sec 4.87 MBytes 4.07 Mbits/sec
[root@wei ~]# iperf -c 192.168.115.130 -p 5001 -i 1 -t 10 -u
------------------------------------------------------------
Client connecting to 192.168.115.130, UDP port 5001
Sending 1470 byte datagrams, IPG target: 11215.21 us (kalman adjust)
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.115.130 port 56882 connected with 192.168.115.130 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 129 KBytes 1.06 Mbits/sec
[ 3] 1.0- 2.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 2.0- 3.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 3.0- 4.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 4.0- 5.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 5.0- 6.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 6.0- 7.0 sec 129 KBytes 1.06 Mbits/sec
[ 3] 7.0- 8.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 8.0- 9.0 sec 128 KBytes 1.05 Mbits/sec
read failed: Connection refused
[ 3] WARNING: did not receive ack of last datagram after 1 tries.
[ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec
[ 3] Sent 891 datagrams
给自己的虚拟机安装tcpdump抓包工具
[root@test-server ~]# yum install tcpdump -y
[root@test-server ~]# ping www.baidu.com
PING www.a.shifen.com (39.156.66.14) 56(84) bytes of data.
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=1 ttl=128 time=17.1 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=2 ttl=128 time=19.4 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=3 ttl=128 time=17.0 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=4 ttl=128 time=16.4 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=5 ttl=128 time=16.7 ms
^C
--- www.a.shifen.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 16.466/17.354/19.438/1.080 ms
打开另外一个终端,ping 8.8.8.8
[root@wei ~]# ping 8.8.8.8 -c 5
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=202 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=203 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=203 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=128 time=204 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=128 time=203 ms
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 202.787/203.608/204.057/0.468 ms
通过ssh登录到自己的虚拟机
[root@wei ~]# ssh root@192.168.115.128
The authenticity of host '192.168.115.128 (192.168.115.128)' can't be established.
ECDSA key fingerprint is SHA256:oSJzRfyAgU9/pgEB1+7HJIX024NOd4lI9YZTkNvIegY.
ECDSA key fingerprint is MD5:0b:4a:e5:53:76:53:f2:3f:d2:97:36:93:e8:40:b1:51.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.115.128' (ECDSA) to the list of known hosts.
root@192.168.115.128's password:
Last login: Mon Oct 26 14:48:39 2020 from 192.168.115.1
[root@test-server ~]#
使用虚拟机的浏览器访问www.sina.com.cn网站
使用tcpdump抓取和8.8.8.8通信的icmp报文,并保存到文件
[root@test-server /]# tcpdump -i ens33 -c 10 -w cap02 host 8.8.8.8
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
10 packets captured
10 packets received by filter
0 packets dropped by kernel
使用tcpdump抓取网络中的SSH报文,并保存文件
[root@test-server /]# tcpdump -i ens33 -c 10 -w cap01 port 22
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
10 packets captured
10 packets received by filter
0 packets dropped by kernel
使用tcpdump抓取网络中的访问www.sina.com.cn的http流量
[root@test-server /]# tcpdump -i ens33 -c 10 host www.sina.com.cn and port \(80 or 443\)
使用tcmdump抓取网络中自己主机和www.baidu.com的ping包
[root@test-server /]# tcpdump -i ens33 -c 5 host www.baidu.com
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
19:14:56.607451 IP test-server > 220.181.38.149: ICMP echo request, id 11422, seq 1, length 64
19:14:56.620080 IP 220.181.38.149 > test-server: ICMP echo reply, id 11422, seq 1, length 64
19:14:57.609327 IP test-server > 220.181.38.149: ICMP echo request, id 11422, seq 2, length 64
19:14:57.622289 IP 220.181.38.149 > test-server: ICMP echo reply, id 11422, seq 2, length 64
19:14:58.611161 IP test-server > 220.181.38.149: ICMP echo request, id 11422, seq 3, length 64
5 packets captured
9 packets received by filter
0 packets dropped by kernel
使用iftop实时监控自己的网卡流量,并截图保存结果
打开2台虚拟机,并让其能够互相通信
在VM1上使用SSH命令行登录到VM2上
在VM1上远程执行命令,目的是在VM2的根目录下创建一个目录:/pro/caiwubu
[root@wei /]# mkdir /pro/caiwubu -p
[root@wei /]# cd /pro
[root@wei pro]# ls
caiwubu
在VM1上使用命令行下载工具下载python最新版本源码包
[root@test-server /]# wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
将VM1上下载的python最新源码包远程复制到VM2上
[root@test-server /]# scp python-3.9.0.tar.xz root@192.168.115.128:/
远程执行命令将VM2上的python源码包解压到/usr/src目录中
[root@wei ~]# tar -Jxvf Python-3.9.0.tar.xz -C /usr/src/