服务器主机网络测试命令

发布于:2025-02-11 ⋅ 阅读:(138) ⋅ 点赞:(0)

适用场景:测试宿主机的出公网带宽流量

安装服务speedtest-cli

sudo yum install python-pip
pip install speedtest-cli  # 这里有可能会遇到网络不通,会连接github地址

# 建议使用阿里云地址,下面是http,这里可以换成https
pip install -i http://mirrors.aliyun.com/pypi/web/simple  --trusted-host mirrors.aliyun.com speedtest-cli
Collecting speedtest-cli
Downloading http://mirrors.aliyun.com/pypi/web/packages/9f/39/65259b7054368b370d3183762484fa2c779ddc41633894d895f9d1720f45/speedtest_cli-2.1.3-py2.py3-none-any.whl
Installing collected packages: speedtest-cli
Successfully installed speedtest-cli-2.1.3   # 看到successfully 就说明安装成功了

运行speedtest测试网速

speedtest-cli --simple

# 输出结果
Ping: 7.843 ms
Download: 748.19 Mbit/s
Upload: 426.23 Mbit/s

适用场景:测试两个宿主机之间的带宽流量

安装服务 iperf3

yum -y install iperf3  # 服务端和客户端安装

命令概述

# 服务端 操作命令启动  
]# iperf3 -s  # 输入成功后 宿主机会运行一个服务端程序,上面会启动一个5201端口号提供给客户端连接

# 客户端 操作命令 启动 
]# iperf3 -c (10.50.10.202)# 这里输入的IP地址是服务端的IP地址,这里默认连接5201端口,如果服务端非5201 需要-p 指定端口号

示例命令

# 服务端和客户端安装 
yum -y install iperf3
# 服务端 操作命令启动  
]# iperf3 -s 

# 示例命令  服务端 10.10.78.5
[root@localhost admin]# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

# 客户端 操作命令 启动  
]# iperf3 -c (ip地址)

# 验证命令
]# iperf3 -c 10.10.78.5
Connecting to host 10.10.78.5, port 5201
[  4] local 10.10.110.202 port 55518 connected to 10.10.78.5 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   114 MBytes   958 Mbits/sec   57    107 KBytes       
[  4]   1.00-2.00   sec   111 MBytes   933 Mbits/sec   22    205 KBytes       
[  4]   2.00-3.00   sec   110 MBytes   923 Mbits/sec   22    163 KBytes       
[  4]   3.00-4.00   sec   111 MBytes   933 Mbits/sec   16    178 KBytes       
[  4]   4.00-5.00   sec   111 MBytes   933 Mbits/sec   20    151 KBytes       
[  4]   5.00-6.00   sec   111 MBytes   933 Mbits/sec   14    133 KBytes       
[  4]   6.00-7.00   sec   110 MBytes   923 Mbits/sec   12    339 KBytes       
[  4]   7.00-8.00   sec   111 MBytes   933 Mbits/sec   25    187 KBytes       
[  4]   8.00-9.00   sec   111 MBytes   933 Mbits/sec   16    182 KBytes       
[  4]   9.00-10.00  sec   111 MBytes   933 Mbits/sec   10    153 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  1.09 GBytes   934 Mbits/sec  214             sender
[  4]   0.00-10.00  sec  1.08 GBytes   931 Mbits/sec                  receiver

iperf Done.


网站公告


今日签到

点亮在社区的每一天
去签到