【原文链接】CentOS7系统安装KVM并配置网桥
(1)首先检查系统是否支持虚拟化
grep vmx /proc/cpuinfo
(2)若上述结果什么都没有,说明不支持虚拟化,如果是VMware安装的虚拟机,则编辑虚拟机如下的位置,然后重启
(4)安装KVM
yum -y install qemu-kvm libvirt virt-install bridge-utils
(5)验证kvm是否安装成功
lsmod | grep kvm
(6)启动libvirt服务并设置为开机自启动
systemctl start libvirtd
systemctl enable libvirtd
(7)关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
(8)关闭selinux
vi /etc/sysconfig/selinux
(8)开启主机透传功能
echo "options kvm_intel nested=1" >> /etc/modprobe.d/kvm-nested.conf
通过如下命令可以查看透传为否启动
cat /sys/module/kvm_intel/parameters/nested
(9)然后reboot重启,重启后再次使用如下命令查看是否开启透传
cat /sys/module/kvm_intel/parameters/nested
可以发现重启后已经显示Y了,表示已经开启了
(2)备份ens33的网卡
[root@CentOS7-1 ~]# cd /etc/sysconfig/network
network network-scripts/
[root@CentOS7-1 ~]# cd /etc/sysconfig/network
network network-scripts/
[root@CentOS7-1 ~]# cd /etc/sysconfig/network-scripts/
[root@CentOS7-1 network-scripts]# ls
ifcfg-ens33 ifdown-bnep ifdown-ippp ifdown-post ifdown-sit ifdown-tunnel ifup-bnep ifup-ippp ifup-plip ifup-ppp ifup-Team ifup-wireless network-functions-ipv6
ifcfg-lo ifdown-eth ifdown-ipv6 ifdown-ppp ifdown-Team ifup ifup-eth ifup-ipv6 ifup-plusb ifup-routes ifup-TeamPort init.ipv6-global
ifdown ifdown-ib ifdown-isdn ifdown-routes ifdown-TeamPort ifup-aliases ifup-ib ifup-isdn ifup-post ifup-sit ifup-tunnel network-functions
[root@CentOS7-1 network-scripts]# cp ifcfg-ens33 ifcfg-ens33.bark
[root@CentOS7-1 network-scripts]# ls
ifcfg-ens33 ifdown ifdown-ib ifdown-isdn ifdown-routes ifdown-TeamPort ifup-aliases ifup-ib ifup-isdn ifup-post ifup-sit ifup-tunnel network-functions
ifcfg-ens33.bark ifdown-bnep ifdown-ippp ifdown-post ifdown-sit ifdown-tunnel ifup-bnep ifup-ippp ifup-plip ifup-ppp ifup-Team ifup-wireless network-functions-ipv6
ifcfg-lo ifdown-eth ifdown-ipv6 ifdown-ppp ifdown-Team ifup ifup-eth ifup-ipv6 ifup-plusb ifup-routes ifup-TeamPort init.ipv6-global
[root@CentOS7-1 network-scripts]#
(3)修改ens33网卡信息
vi ifcfg-ens33
将网卡修改为如下内容,其中ens33为网卡名,需要根据具体网卡名修改
TYPE="Ethernet"
NAME="ens33"
DEVICE="ens33"
ONBOOT="yes"
BRIDGE=br0
(4)根据ens33网卡配置文件复制出一份br0的配置文件
cp ifcfg-ens33 ifcfg-br0
(5)编辑网桥配置文件
vi ifcfg-br0
修改内容如下,注意IPADDR和GATEWAY要根据具体的环境修改
TYPE="Bridge"
BOOTPROTO="static"
NAME="br0"
IPADDR=192.168.1.11
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DEVICE="br0"
ONBOOT="yes"
DNS1=114.114.114.114
DNS2=8.8.8.8
(6)然后重启网络
systemctl restart network
(7)重启libvirted服务
systemctl restart libvirtd
(8)查看网桥
brctl show
(9)开启stp服务,防止环路
brctl stp br0 yes
(10)至此网桥配置完成了