安装必须的几个库和软件(最好下载一个163的yum源,速度快点)
$ yum -y install kvm python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2v
$ /sbin/lsmod | grep kvm查看kvm模块
$ service libvirtd restart 启动libvirtd
$ chkconfig libvirtd on设置虚拟机服务开机启动
$ cd /etc/sysconfig/network-scripts/去备份之前网卡信息
$ touch /etc/sysconfig/network-scripts/ifcfg-br0 创建网桥配置文件
$ service NetworkManager stop #停止网卡守护进程
$ chkconfig NetworkManager off#关闭网络管理,让桥接生效
- service NetworkManager stop //这个关闭掉就行
- 停止 NetworkManager 守护进程: [确定]
配置网卡和网桥
#vim ifcfg-br0编辑网桥内容(为了防止断网可以写好脚本和配置文件直接替换后重启网卡)
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
IPV6INIT=no
ONBOOT=yes
IPADDR=192.168.10.10
NETMASK=255.255.255.0
GATEWAY=192.168.10.1
DNS1=1.2.4.8
DNS2=114.114.114.114
#把宿主机物理网卡添加到网桥(vim /etc/sysconfig/network-scripts/ifcfg-p2p1)
DEVICE=p2p1
TYPE=Ethernet
ONBOOT=yes
IPV6INIT=no
BOOTPROTO=none
BRIDGE=br0
###配置网桥脚本###
#!/bin/bash
mkdir -p /home/bak
cp /etc/sysconfig/network-scripts/ifcfg* /home/bak
yes | mv ifcfg* /etc/sysconfig/network-scripts
sleep 2
service network restart
#连上后杀掉脚本进程,连不上恢复之前配置
sleep 500
yes | mv /home/bak/ifcfg* /etc/sysconfig/network-scripts