大网数据广告活动
服务器运维问答

How to create network bridge for KVM with nmcli?

· 52CE 我爱测

I used to create a network bridge on CentOS 7 as seen below, where I would disable NetworkManager and edit the config files by hand. However I would like to do it with nmcli and therefore use NetworkManager. This article says it …

问题原文

原帖链接 · Sandra · CC BY-SA 4.0

I used to create a network bridge on CentOS 7 as seen below, where I would disable NetworkManager and edit the config files by hand.

However I would like to do it with nmcli and therefore use NetworkManager.

This article says it is done by

nmcli con add ifname br0 type bridge con-name br0
nmcli con add type bridge-slave ifname eno1 master br0
nmcli connection show

but doesn't explain why of a sudden a bridge-slave is introduced and what it is for.

Question

Can anyone explain what a bridge-slave is and if these 3 commands are indeed the way to create a network bridge for KVM?

cd /etc/sysconfig/network-scripts
cp ifcfg-eno1 _ifcfg-eno1.backup

cat << EOF > /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
IPADDR=xxx.xxx.xx.xx
PREFIX=22
BOOTPROTO=none
ONBOOT=yes
DELAY=0
NM_CONTROLLED=no
DNS1=xx.xxx.xx.x
DNS2=xx.xxx.xx.x
GATEWAY=x.xxx.xx.x
EOF

cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eno1
HWADDR=A0:D3:C1:05:C3:30
DEVICE=eno1
TYPE=Ethernet
NAME=eno1
BOOTPROTO=none
ONBOOT=yes
BRIDGE=br0
NM_CONTROLLED=no
EOF

systemctl stop NetworkManager.service
systemctl disable NetworkManager.service

systemctl restart network

已采纳解答

原帖链接 · Jan-Marten Brüggemann · CC BY-SA 4.0

A network bridge (in this case) is a virtual interface that joins one ore more network interfaces. It can be compared with a switch. If you add an interface, in this example eno1 (your physical network interface) to the bridge, it is called a slave of the bridge.

The idea is, to add the physical interface to the bridge (this is, what "nmcli con add type bridge-slave ifname eno1 master br0" does) and do the IP configuration on the bridge-interface instead of the phsyical interface.

If you now create a VM and connect it to your br0 interface, the VM's network adapter will be a slave of br0, too. So you have some kind of switched networking between the VM's network adapter and eno1.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-10-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。