首页 > 系统相关 >Linux常用网络配置练习(2)

Linux常用网络配置练习(2)

时间:2023-08-19 13:33:27浏览次数:50  
标签:常用 Mbits 8.8 0.00 练习 192.168 sec Linux 128

打开第二台虚拟机(带图形界面的虚拟机)

Linux常用网络配置练习(2)_练习

使用浏览器访问一些网站,然后统计这些连接处于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

打开一个终端,ping www.baidu.com

[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 [email protected]
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.
[email protected]'s password: 
Last login: Mon Oct 26 14:48:39 2020 from 192.168.115.1
[root@test-server ~]#

使用虚拟机的浏览器访问www.sina.com.cn网站

Linux常用网络配置练习(2)_UDP_02

使用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实时监控自己的网卡流量,并截图保存结果

Linux常用网络配置练习(2)_练习_03

打开2台虚拟机,并让其能够互相通信

Linux常用网络配置练习(2)_练习_04

在VM1上使用SSH命令行登录到VM2上

Linux常用网络配置练习(2)_练习_05

在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 [email protected]:/

远程执行命令将VM2上的python源码包解压到/usr/src目录中

[root@wei ~]# tar -Jxvf Python-3.9.0.tar.xz -C /usr/src/

标签:常用,Mbits,8.8,0.00,练习,192.168,sec,Linux,128
From: https://blog.51cto.com/u_16206331/7148981

相关文章

  • linux下进程间通信
    进程间通信一、进程间通信的介绍1、进程间通信的概念进程通信(Interprocesscommunication),简称:IPC;本来进程之间是相互独立的。但是由于不同的进程之间可能要共享某些信息,所以就必须要有通讯来实现进程间的互斥和同步。比如说共享同一块内存、管道、消息队列、信号量等等就是实......
  • Linux命令
    常用命令命令ls-a这个选项能显示.开头的隐藏文件-i显示每个文件的inode号-m所有项目以逗号分隔,并填满整行行宽-R同时列出所有子目录层-h将列出文件的大小以人性化格式输出ls-lc[文件名]查看文件的访问时间ls-lu[文件名]查看文件的最后修改时间ls-l显示文件的......
  • linux下gcc/g++创建一个共享库项目以及创建一个可执行项目动态链接该共享库
    1.先确保有g++命令2.创建一个c++项目目录,并cd到该目录3.创建共享库头文件:dynamic_so.h#ifndef__TEST__#define__TEST__inttestFun(inta,intb);#endif4.创建对应共享库的实现文件:dynamic_so.cpp#include"dynamic_so.h"inttestFun(inta,intb){returna......
  • linux环境下基于python的OpenCV 保存视频
    一概念在OpenCV中保存视频使用的是VedioWriter对象,在其中指定输出文件的名称,A创建视频写入的对象out=cv2.VideoWriter(filename,fourcc,fps,frameSize)参数含义:filename:视频保存的位置fourcc:指定视频编解码器的4字节代码fps:帧率frameSize:帧大小B 设置视频的编解......
  • 基于 Debian 12 的MX Linux 23 正式发布!
    MX Linux 是基于Debian稳定分支的面向桌面的Linux发行,它是antiX及早先的MEPISLinux社区合作的产物。它采用Xfce作为默认桌面环境,是一份中量级操作系统,并被设计为优雅而高效的桌面与如下特性的结合:配置简单、高度稳定、性能可靠、占用空间不大也不小。新版本......
  • C++中String的语法及常用接口用法
    在C语言中,string是一个标准库类(class),用于处理字符串,它提供了一种更高级、更便捷的字符串操作方式,string 类提供了一系列成员函数和重载运算符,以便于对字符串进行操作和处理。一、string类在学习string前,我们不妨先来了解一下string类到底是什么,有什么用呢?我们先来了解一下基本......
  • Hadoop3.3.0--Linux编译安装
    Hadoop3.3.0--Linux编译安装本实验内容教程来源于“黑马程序员”如有侵权请联系作者删除基础环境:Centos7.7编译环境软件安装目录mkdir-p/export/server一、Hadoop编译安装(选做)可以直接使用课程提供已经编译好的安装包。安装编译相关的依赖yuminstallgccgcc-c+......
  • Linux unixODBC 连接 MySQL数据库
    LinuxunixODBC连接MySQL数据库1.下载unixODBC及MySQLConnector/ODBC1.1unixODBC下载https://www.unixodbc.org/ 1.2MySQLConnector/ODBC下载https://downloads.mysql.com/archives/c-odbc/选择版本选择:5.3.132. 安装驱动安装unixODBCtar-zxvfunix......
  • c++ 常用的 STL
    c++中常用的STLvector//vector变长数组倍增的思想(倍增:系统为每一个程序分配空间的时候,所需要的时间和空间大小无关,与请求次数相关)尽量减少请求的次数/*返回元素的个数size()判断是否为空empty()清空clear()front()返回第一个数back()返回最后一个数push......
  • linux虚拟机中各服务端口及配置文件路径
    查询端口状况命令:netstat-an|grep端口号查询服务状态(服务是否开启)命令:systemctl  status服务名开启服务命令:systemctl  start  服务名21端口:FTP文件传输服务22端口:SSH协议、SCP(文件传输)、端口号重定向23/tcp端口:TELNET终端仿真服务25端口:SMTP简单邮件传输服务53......