简介
在 QEMU/KVM 的网络使用中,桥接模式可以让虚拟机需物理机共享一个物理网络设备连接外部网络,虚拟机有自己独立的 IP 地址,可以访问外部网络,外部网络也可以访问虚拟机。
优缺点:使用桥接模式配置简单,但如果你的网络环境是ip资源很缺少或对ip管理比较严格的话,那桥接模式就不太适用了
桥接模式网络配置步骤
1. 安装 bridge-utils 软件包,它提供 brctl 工具来配置网桥
yum install bridge-utils
2. 加载 tun 和 bridge 模块
[root@localhost ~]# lsmod | grep tun
tun 36164 2 vhost_net
[root@localhost ~]#
[root@localhost ~]# lsmod | grep bridge
bridge 151336 1 ebtable_broute
stp 12976 1 bridge
llc 14552 2 stp,bridge
[root@localhost ~]#
3. 创建 brdige
将物理机工作的网口绑定到 brdige 上,将网口 IP 清除,让 bridge 获取 IP
root@localhost:~# brctl addbr br0
root@localhost:~# brctl addif br0 enp3s0
root@localhost:~# brctl show br0
bridge name bridge id STP enabled interfaces
br0 8000.eef79549afe7 no enp3s0
root@localhost:~#
root@localhost:~# brctl stp br0 on
root@localhost:~#
root@localhost:~# brctl show br0
bridge name bridge id STP enabled interfaces
br0 8000.eef79549afe7 yes enp3s0
root@localhost:~#
root@localhost:~#
root@local