对于KVM虚拟机,可以在宿主机上模拟网卡的通断,具体步骤如下(以下步骤均在宿主机上执行):
1.查询客户机网络情况:
#virsh qemu-monitor-command --hmp hatest01 "info network"
Devices not on any VLAN:
hostnet0: fd=25 peer=net0
hostnet1: fd=29 peer=net1
net0: model=virtio-net-pci,macaddr=52:54:00:61:18:8d peer=hostnet0
net1: model=virtio-net-pci,macaddr=52:54:00:9b:b2:c0 peer=hostnet1
hmp后跟的是客户机的名称,可以通过virsh list查到
通过macaddr来确定具体的网卡
2.模拟断开网络:
#virsh qemu-monitor-command --hmp hatest01 "set_link net0 off"
3.模拟网络恢复
#virsh qemu-monitor-command --hmp hatest01 "set_link net0 on"
阅读(896) | 评论(0) | 转发(0) |