模拟网络故障
本文主要介绍如何使用 Chaosd 模拟网络故障场景。该功能通过使用 iptables、ipsets、tc 等工具修改网络路由、流量控制来模拟网络故障。
注意
请确保 Linux 内核中有 NET_SCH_NETEM
模块。对于 CentOS,可以通过 kernel-modules-extra
包安装该模块,大部分其他发行版默认已安装相应模块。
使用命令行模式创建网络故障实验
本节介绍如何在命令行模式创建网络故障实验。
在创建网络故障实验前,可以运行以下命令查看 Chaosd 支持的网络故障类型:
chaosd attack network --help
输出结果如下所示:
Network attack related commands
Usage:
chaosd attack network [command]
Available Commands:
bandwidth limit network bandwidth
corrupt corrupt network packet
delay delay network
dns attack DNS server or map specified host to specified IP
duplicate duplicate network packet
loss loss network packet
partition partition
port attack network port
Flags:
-h, --help help for network
Global Flags:
--log-level string the log level of chaosd, the value can be 'debug', 'info', 'warn' and 'error'
Use "chaosd attack network [command] --help" for more information about a command.