Skip to content

Instantly share code, notes, and snippets.

@gotnix
Last active June 12, 2018 10:38
Show Gist options
  • Save gotnix/004c4e077a8e40c72de08702a0b92c8f to your computer and use it in GitHub Desktop.
Save gotnix/004c4e077a8e40c72de08702a0b92c8f to your computer and use it in GitHub Desktop.
virsh 重启虚拟网络以后,虚拟机的虚拟机网卡不会自动重连,能不能搞成自动把虚拟机的网卡加到网桥里?
虚拟机有 2 台
» virsh list --title --all
 Id    Name               State      Title
--------------------------------------------------
 5     vm-01             running    192.168.2.110
 6     vm-02             running    192.168.2.111
虚拟网络 2 个
» virsh net-list
Name                 State      Autostart     Persistent
--------------------------------------------------
default              active     yes           yes
host-bridge          active     yes           yes
default 虚拟网络信息
» virsh net-info default
Name            default
UUID            96b5a0a2-fc58-4ffb-9ba3-220ce954cdd5
Active:         yes
Persistent:     yes
Autostart:      yes
Bridge:         virbr0
虚拟网络链接情况
» brctl show virbr0
bridge name     bridge id               STP enabled     interfaces
virbr0          8000.525400319e05       yes             virbr0-nic
                                                        vnet0
                                                        vnet2

» virsh domiflist vm-01
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      network    default    virtio      52:54:00:d1:74:83
vnet1      network    host-bridge virtio      52:54:00:36:70:c2

» virsh domiflist vm-02
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet2      network    default    virtio      52:54:00:d3:78:cc
vnet3      network    host-bridge virtio      52:54:00:23:0f:27
重启 default 虚拟网络
» virsh net-destroy default && virsh net-start default
Network default destroyed
Network default started

虚拟网络重启之后, virsh domiflist 看到信息和虚拟网络重启之前一样,但是虚拟网络使用的网桥的配置不同。

网桥状态,虚拟机的虚拟网卡不会自动重连的网桥上
» brctl show virbr0
bridge name     bridge id               STP enabled     interfaces
virbr0          8000.525400319e05       yes             virbr0-nic
需要手动添加,Guest 的网络才正常
» brctl addif virbr0 vnet0; brctl addif virbr0 vnet2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment