KVM的默认网络模式为NAT,就是说借助宿主机模式上网,现在我们想改成桥接模式,这样外界就可以直接和宿主机里的虚拟机通讯了。 1,首先看一下默认的网络设置 复制代码代码如下: # cat /etc/libvirt/qemu/networks/default.xml <network> <name>default</name> <uuid>1f---adcf-6bf6acac</uuid> <bridge name="virbr0" /> <mac address=':::F1:6B:6E'/> <forward/> <ip address="...1" netmask="...0"> <dhcp> <range start="...2" end="..." /> </dhcp> </ip> </network> 2,再看一下虚拟机配置文件里面的网络设置 #cat /etc/libvirt/qemu/ubuntu..xml <!-- WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE OVERWRITTEN AND LOST. Changes to this xml configuration should be made using: virsh edit ubuntu. or other application using the libvirt API. --> <domain type='kvm'> <name>ubuntu.</name> <uuid>2eeb-a2-a-4da3-fba1df</uuid> <memory unit='KiB'></memory> <currentMemory unit='KiB'></currentMemory> <vcpu placement='static'>1</vcpu> <os> <type arch='x_' machine='rhel6.3.0'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source file='/var/lib/libvirt/images/ubuntu..img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x' bus='0x' slot='0x' function='0x0'/> </disk> <disk type='block' device='cdrom'> <driver name='qemu' type='raw'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <controller type='usb' index='0'> <address type='pci' domain='0x' bus='0x' slot='0x' function='0x2'/> </controller> <controller type='ide' index='0'> <address type='pci' domain='0x' bus='0x' slot='0x' function='0x1'/> </controller> <interface type='bridge'> 原来是interface type='default' <mac address=':::::7e'/> <source bridge='br1'/> 原来是source network='default',这里的br1要根据你的物理网卡下面有讲 <model type='virtio'/> <address type='pci' domain='0x' bus='0x' slot='0x' function='0x0'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'/> <sound model='ich6'> <address type='pci' domain='0x' bus='0x' slot='0x' function='0x0'/> </sound> <video> <model type='cirrus' vram='' heads='1'/> <address type='pci' domain='0x' bus='0x' slot='0x' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x' bus='0x' slot='0x' function='0x0'/> </memballoon> </devices> </domain> [/code] 3,改完之后要更新一下配置文件 # virsh define ubuntu..xml 定义域 ubuntu.(从 ubuntu..xml) #然后就可以virsh start ubuntu.了,不过现在物理网卡这块还没有改好 4,物理网卡可以手动更改,不过现在有现成的工具包,可以用这个更改 #wget # tar zxvf convirture-tools-2.0.1.tar.gz # /root/convirture-tools/install/managed_server/scripts/convirt-tool --bridge setup 我的这里出现了点小问题,发现网络没起来,所以不要远程来做这个操作,主要原因是里面的配置文件有点需要 小的更改,我的是UUID注释了。 # ls ifcfg-* ifcfg-br1 ifcfg-br2 ifcfg-br3 ifcfg-br4 ifcfg-em1 ifcfg-em2 ifcfg-em3 ifcfg-em4 ifcfg-lo 我这里有四个物理网卡,所以生成了四个bridge,不过真实用的只有br1 这个工具好有一个好处就是保存了原配置文件,如果你不想用时还可以还原 # ls saved.ifcfg-em* saved.ifcfg-em1.. saved.ifcfg-em3.. saved.ifcfg-em2.. saved.ifcfg-em4.. 看下ifceg-em1 # cat ifcfg-em1 DEVICE="em1" #BOOTPROTO=none NM_CONTROLLED="yes" ONBOOT=yes TYPE="Ethernet" #UUID="3bc7fdcc-b1--b-ec8" #IPADDR... PREFIX= GATEWAY=... DNS1=...5 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System em1" HWADDR=:B1:1C::4D:A5 BRIDGE=br1 看下ifcfg-br1 # cat ifcfg-br1 DEVICE="br1" BOOTPROTO=none NM_CONTROLLED="yes" ONBOOT=yes #UUID="3bc7fdcc-b1--b-ec8" IPADDR=... PREFIX= GATEWAY=... DNS1=...5 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System br1" TYPE=Bridge 最后看下网卡 # ifconfig br1 Link encap:Ethernet HWaddr :B1:1C::4D:A5 inet addr:... Bcast:... Mask:...0 inet6 addr: fe::b1:1cff:fe:4da5/ Scope:Link UP BROADCAST RUNNING MULTICAST MTU: Metric:1 RX packets: errors:0 dropped:0 overruns:0 frame:0 TX packets: errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes: (.5 KiB) TX bytes: (.1 MiB) em1 Link encap:Ethernet HWaddr :B1:1C::4D:A5 inet6 addr: fe::b1:1cff:fe:4da5/ Scope:Link UP BROADCAST RUNNING MULTICAST MTU: Metric:1 RX packets: errors:0 dropped:0 overruns:0 frame:0 TX packets: errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen: RX bytes: (.7 KiB) TX bytes: (.7 MiB) Interrupt: lo Link encap:Local Loopback inet addr:.0.0.1 Mask:.0.0.0 inet6 addr: ::1/ Scope:Host UP LOOPBACK RUNNING MTU: Metric:1 RX packets: errors:0 dropped:0 overruns:0 frame:0 TX packets: errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes: (.5 MiB) TX bytes: (.5 MiB) virbr0 Link encap:Ethernet HWaddr :::F1:6B:6E inet addr:...1 Bcast:... Mask:...0 UP BROADCAST RUNNING MULTICAST MTU: Metric:1 RX packets: errors:0 dropped:0 overruns:0 frame:0 TX packets: errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes: (.8 KiB) TX bytes: (.2 KiB) vnet0 Link encap:Ethernet HWaddr FE:::::7E inet6 addr: fe::fc:ff:fe:e/ Scope:Link UP BROADCAST RUNNING MULTICAST MTU: Metric:1 RX packets: errors:0 dropped:0 overruns:0 frame:0 TX packets: errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen: RX bytes: (.1 KiB) TX bytes: (.7 KiB) vnet1 Link encap:Ethernet HWaddr FE:::B5:1A: inet6 addr: fe::fc:ff:feb5:1a/ Scope:Link UP BROADCAST RUNNING MULTICAST MTU: Metric:1 RX packets: errors:0 dropped:0 overruns:0 frame:0 TX packets: errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen: RX bytes: (8.5 KiB) TX bytes: (.2 KiB) 5,启动虚拟机ubuntu.后配置网卡 #cat /etc/network/interface auto lo iface lo inet loopback auto eth0 iface eth0 inet static address ... netmask ...0 gateway ... #/etc/init.d/networking restart 启动即可
推荐整理分享CentOS6.3 KVM如何设置网卡为桥接模式(centos7.6安装kvm),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:centos kvm win7,centos安装kvm图形界面,centos kvm win7,centos7 kvm,centos7.6安装kvm,centos7 kvm,centos kvm win7,基于centos6安装kvm服务,内容如对您有帮助,希望把文章链接给更多的朋友!
linux backtrak无线配置教程 俺用backtrack不是为了破解,就是因为看到它有一句话说的很多thequieteryoubecome,themoreyouareabletohear.我说一下backtrack是如何无线上网的哈,其实bt的内核是ubun
Linux构造磁盘空间满的测试环境解决方案 利用suse操作系统的ramdisk,来挂接虚拟磁盘分区,然后通过填满虚拟磁盘分区来实现磁盘满环境的条件。ramdisk是操作系统自带的一种内存块设备,这种设备
Linux系统进程深入理解 1.什么是进程进程是处于执行期的程序以及它所包含的所有资源的总称,包括虚拟处理器,虚拟空间,寄存器,堆栈,全局数据段等。在Linux中,每个进