CentOS6.3 KVM下设置网卡为桥接模式
KVM的默认网络模式为NAT,就是说借助宿主机模式上网,现在我们想改成桥接模式,这样外界就可以直接和宿主机里的虚拟机通讯了。
1,首先看一下默认的网络设置
# cat /etc/libvirt/qemu/networks/default.xml
<network>
<name>default</name>
<uuid>1f118032-0345-4725-adcf-6b94f6aca19c</uuid>
<bridge name="virbr0" />
<mac address='52:54:00:F1:6B:6E'/>
<forward/>
<ip address="192.168.122.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.122.2" end="192.168.122.254" />
</dhcp>
</ip>
</network>
2,再看一下虚拟机配置文件里面的网络设置
#cat /etc/libvirt/qemu/Ubuntu10.04.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 ubuntu10.04
or other application using the libvirt API.
-->
<domain type='kvm'>
<name>ubuntu10.04</name>
<uuid>2eeb1395-39a2-a169-4da3-f22b20a1d34f</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' 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/ubuntu10.04.img'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' 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='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='bridge'> 原来是interface type='default'
<mac address='52:54:00:50:58:7e'/>
<source bridge='br1'/> 原来是source network='default',这里的br1要根据你的物理网卡下面有讲
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' 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='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
</domain>
3,改完之后要更新一下配置文件
# virsh define ubuntu10.04.xml
定义域 ubuntu10.04(从 ubuntu10.04.xml)
#然后就可以virsh start ubuntu10.04了,不过现在物理网卡这块还没有改好
1,首先看一下默认的网络设置
# cat /etc/libvirt/qemu/networks/default.xml
<network>
<name>default</name>
<uuid>1f118032-0345-4725-adcf-6b94f6aca19c</uuid>
<bridge name="virbr0" />
<mac address='52:54:00:F1:6B:6E'/>
<forward/>
<ip address="192.168.122.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.122.2" end="192.168.122.254" />
</dhcp>
</ip>
</network>
2,再看一下虚拟机配置文件里面的网络设置
#cat /etc/libvirt/qemu/Ubuntu10.04.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 ubuntu10.04
or other application using the libvirt API.
-->
<domain type='kvm'>
<name>ubuntu10.04</name>
<uuid>2eeb1395-39a2-a169-4da3-f22b20a1d34f</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' 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/ubuntu10.04.img'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' 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='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='bridge'> 原来是interface type='default'
<mac address='52:54:00:50:58:7e'/>
<source bridge='br1'/> 原来是source network='default',这里的br1要根据你的物理网卡下面有讲
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' 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='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
</domain>
3,改完之后要更新一下配置文件
# virsh define ubuntu10.04.xml
定义域 ubuntu10.04(从 ubuntu10.04.xml)
#然后就可以virsh start ubuntu10.04了,不过现在物理网卡这块还没有改好
相关推荐
leeham 2020-04-19
成长路上 2020-07-29
zhangsyi 2020-07-28
82911234 2020-07-20
leeham 2020-07-05
81550996 2020-06-07
leeham 2020-06-06
82143754 2020-05-31
zhangsyi 2020-05-31
82911234 2020-05-31
hnllei 2020-05-30
82911234 2020-05-27
辛佳雨 2020-05-16
82143754 2020-05-15
81550996 2020-05-12
81550996 2020-04-30
82911234 2020-04-29
82143754 2020-04-29