一、安装开启libvirt bridge
sudo dnf install libvirt.x86_64 libvirt-daemon.x86_64
sudo dnf install bridge-utils.x86_64
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
二、网络管理小程序
sudo dnf install NetworkManager.x86_64
sudo systemctl start NetworkManager
sudo dnf install nm-connection-editor
命令行工具
nmtui
窗口工具
nm-connection-editor
三、qemu使用桥时错误
在源码安装时如果没有配置--sysconfdir=/etc,那么就在--prefix=目录下,如果也没有配置--frefix=,大部分是默认安装,也是就是在
/usr/local或/usr
出现错误后,可根据实际路径进行修改.
failed to create tun device: Operation not permitted
权限的问题,提升用户权限
chmod +s /usr/local/libexec/qemu-bridge-helper
配置文件错误
failed to parse default acl file `/usr/local/libexec/../etc/qemu/bridge.conf'
执行文件及配置文件问题,开始搞不明白,查阅官网也没解决。
不能停止不前啊,索性看一源码吧
grep -rn bridge.conf
发现存在于下面这个文件中
qemu-bridge-helper.c
看过之后,终于发现文件及其路径配置问题
sudo mkdir /usr/local/etc/qemu
sudo vi /usr/local/etc/qemu/bridge.conf
添加
allow virbr0
allow all
修改文件权限
sudo chmod 777 /usr/local/etc/qemu/bridge.conf
注:通过dnf yum apt安装qemu
bridge.conf文件被强制定位于
/etc/qemu/bridge.conf
可根据实际情况进行修改
四、几个命令
brctl --help
详细使用,这上面已经很详细了。
addbr <bridge> add bridge
delbr <bridge> delete bridge
addif <bridge> <device> add interface to bridge
delif <bridge> <device> delete interface from bridge
hairpin <bridge> <port> {on|off} turn hairpin on/off
setageing <bridge> <time> set ageing time
setbridgeprio <bridge> <prio> set bridge priority
setfd <bridge> <time> set bridge forward delay
sethello <bridge> <time> set hello time
setmaxage <bridge> <time> set max message age
setpathcost <bridge> <port> <cost> set path cost
setportprio <bridge> <port> <prio> set port priority
show [ <bridge> ] show a list of bridges
showmacs <bridge> show a list of mac addrs
showstp <bridge> show bridge stp info
stp <bridge> {on|off} turn stp on/off
查看联接
brctl show
或用
nmcli connection --help
nmcli connection
nmcli connection down br0
nmcli connection up br0
nmcli connection down enp2s0
enp2s0消失,可以通过dhclient ifconfig 找到
重新
nmcli connection up enp2s0
ifconfig