一些我用过的网络工具
Published:
回忆了一下我用过的一些简单网络工具并作简单记录
Arista万兆交换机
# 进入交换机配置
enable
configure terminal
show interface status # 查看交换机接口状态
# The default mode setting is CoS trust for switched ports and DSCP trust for routed ports.
switch(config) # 指定interface ethernet 15
switch(config-if-Et15) # 设置dscp模式:qos trust dscp
# 注意:信息不同的交换机的具体dscp/Cos队列映射规则不同需要具体查看
ethstatus 网卡测速
- 功能:监控实时的网卡带宽占用,显示当前网卡的 RX 和 TX 速率,单位是Byte
- 安装:
sudo apt-get install ethstatus - 查看 网卡 的速度:
sudo ethstatus -i eth0
iperf3 网络性能测试
iperf3 -s 服务器地址iperf3 -c 192.168.0.1(目的IP) -b(发送速率) -t(持续时间单位秒)
Wireshark pcap包管理
拆分pcap:editcap -c 1000000(num_pkts) old_file_name.pcap new_file_name_prefix.pcap
p(arallel)ssh 服务器脚本管理
在hosts.txt中列出来的服务器上远程执行uptime命令,并将执行结果输出到/tmp/uptime目录下相应地服务器的文件中:pssh -h hosts.txt -l root -o /tmp/uptime uptime
Netfilter 管理网络数据包
其中的hook函数返回状态NF_STOLEN可将网络数据包暂时“偷”走,在需要的时候通过nf_hook_stat中的okfn()函数回调
Linux Traffic Control 流量控制
- 以
qdisc-class-filter的树形结构来实现对流量的分层控制
htb队列示例用法
(htb有许多需要相互协调参数,若要真正生效,需要对其所有参数有深入理解,具体参数含义搜索引擎可查)
# add qdisc
tc qdisc add dev eth0 root handle 1: htb default 2 r2q 100
# add default class
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 1000mbit ceil 1000mbit
tc class add dev eth0 parent 1:1 classid 1:2 htb prio 5 rate 1000mbit ceil 1000mbit
tc qdisc add dev eth0 parent 1:2 handle 2: pfifo limit 500
# add default filter
tc filter add dev eth0 parent 1:0 prio 5 protocol ip u32
tc filter add dev eth0 parent 1:0 prio 5 handle 3: protocol ip u32 divisor 256
tc filter add dev eth0 parent 1:0 prio 5 protocol ip u32 ht 800:: match ip src 192.168.0.0/16 hashkey mask 0x000000ff at 12 link 3:
# add egress rules for 192.168.0.9
tc class add dev eth0 parent 1:1 classid 1:9 htb prio 5 rate 3mbit ceil 3mbit
tc qdisc add dev eth0 parent 1:9 handle 9: pfifo limit 500
tc filter add dev eth0 parent 1: protocol ip prio 5 u32 ht 3:9: match ip src "192.168.0.9" flowid 1:9
