#networkManger tui 网络图形化 设置IP nmtui cd /etc/sysconfig/network-scripts/ #netplan 绑定mac地址和网卡名称,防止网卡名称变更 cat /etc/netplan/00-installer-config.yaml network: ethernets: etho: match: macaddress: "00:15:b2:b4:a4:16" set-name: "eth0" dhcp4: true version: 2 #查看ip ip addr #设置mtu ip link set dev eth0 mtu 9000 #重启网络服务,通常用于修改文件后操作,如果使用命令则无需操作。 sudo systemctl restart network sudo systemctl restart NetworkManager.service /etc/init.d/networking restart #启动某网卡 sudo ip link set ens192 up sudo nmcli device connect ens192 #对于DHCP自动分配的ip,不能用ifconfig来激活或停止。 dhclient eth0 #网速 sudo apt install -y nload iftop watch -n 1 ip -s link show eth0 nload -u M sudo iftop -B -i eth0 #查看 eth0 网卡的硬件配置信息 ethtool eth0 #亮灯 ethtool -p ens83f0 #查看 eth0 网卡的驱动,以及bus-info,即可通过lspci定位 ethtool -i eth0 #安装lspci yum install pciutils -y #查找网卡 lspci | grep net #busid和网卡对应关系 lshw -class network -businfo #查看槽位带宽,通过vendor id和device id lspci -n | grep 31:00 lspci -nvv -d 8086:1572 | grep --color Width lspci -nvv -d 8086:1572 | grep -i numa #关闭防火墙 systemctl stop firewalld && systemctl disable firewalld systemctl status firewalld systemctl restart network #ping -I指定从该网口192.168.1.1 ping -c100 -I 192.168.1.1 192.168.1.3 > ping.2.out #iperf iperf3同理 yum install -y iperf3 #设置服务端 iperf3 -s #设置客户端 -c 指定目标服务端IP地址 -B bond绑定网卡 iperf3 -c 10.10.1.1 -B 10.10.1.2 #-u udp测试 -P 数据流并发数量 建议使用iperf2进行udp的测试 iperf3 -c 10.10.1.1 -u -b 5G -P 20 #-i 间隔多少秒显示 -t 测试时长 -b 限制测试带宽 -l 读写缓冲区的长度,TCP 默认为 128K,UDP 默认为 8K iperf -c 10.10.1.1 -u -i 1 -t 10 -b 10G -l 16 ###PPS测试 pps=(总包数-丢失包数)/传输时间(120s) #千兆: iperf -t 120 -i 1 -u -b 1G -l 16 -c $serverip #万兆: iperf -t 120 -i 1 -u -b 10G -l 16 -c $serverip #查看 yum install sysstat sar -n DEV 1 320 | grep [网卡名] sar -n DEV 1 300 #netperf https://github.com/HewlettPackard/netperf/releases curl -OL https://codeload.github.com/HewlettPackard/netperf/tar.gz/refs/tags/netperf-2.7.0 cd netperf-netperf-2.7.0 ./configure make make install # make for gcc 10 make clean make CFLAGS=-fcommon #arm ./configure --prefix=/usr/local/netperf --build=arm-linux && make && make install #在测试机上开启服务 -p可以设置端口 cd src/ ./netserver #-H host 指定远端运行 netserver 的 server IP 地址 #-l testlen 指定测试的时间长度 (秒) #-t testname 指定进行的测试类型 (TCP_STREAM,UDP_STREAM,TCP_RR,TCP_CRR,UDP_RR) netperf -H 172.168.5.23 -l 100 #延迟测试 netperf -H $(对端IP) -t omni -- -d rr -O "THROUGHPUT, THROUGHPUT_UNITS, MIN_LATENCY, MAX_LATENCY, MEAN_LATENCY" for i in {1..3} do log=netperf.$i.out ./netperf -H 10.10.1.1 -l 60 -t TCP_STREAM >> $log ./netperf -H 10.10.1.1 -l 60 -t TCP_RR >> $log ./netperf -H 10.10.1.1 -l 60 -t TCP_CRR >> $log ./netperf -H 10.10.1.1 -l 60 -t UDP_RR >> $log ./netperf -H 10.10.1.1 -l 60 -t UDP_STREAM >> $log ./netperf -H 10.10.1.1 -t omni -- -d rr -O "THROUGHPUT, THROUGHPUT_UNITS, MIN_LATENCY, MAX_LATENCY, MEAN_LATENCY" >> $log done for i in {1..3} do log=netperf.$i.out ./netperf -H 192.168.1.39 -l 60 -t TCP_STREAM >> $log ./netperf -H 192.168.1.39 -l 60 -t TCP_RR >> $log ./netperf -H 192.168.1.39 -l 60 -t TCP_CRR >> $log ./netperf -H 192.168.1.39 -l 60 -t UDP_RR >> $log ./netperf -H 192.168.1.39 -l 60 -t UDP_STREAM >> $log ./netperf -H 192.168.1.39 -t omni -- -d rr -O "THROUGHPUT, THROUGHPUT_UNITS, MIN_LATENCY, MAX_LATENCY, MEAN_LATENCY" >> $log done #汇总结果 echo "TCP_STREAM,TCP_RR,TCP_CRR,UDP_RR,UDP_STREAM,UDP_STREAM,Mean LATENCY" > netperf.summary.csv for i in {1..3}; do awk '{print $NF}' netperf.$i.out | grep '\.[0-9][0-9]' | paste -sd',' - >> netperf.summary.csv done