一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Linux|Centos|Ubuntu|系統進程|Fedora|注冊表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服務器之家 - 服務器系統 - Centos - CentOS6.3 KVM如何設置網卡為橋接模式

CentOS6.3 KVM如何設置網卡為橋接模式

2019-12-13 13:40CentOS教程網 Centos

KVM的默認網絡模式為NAT,就是說借助宿主機模式上網,現在我們想改成橋接模式,這樣外界就可以直接和宿主機里的虛擬機通訊了,本文將介紹此方法的實現

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> 
[/code] 
3,改完之后要更新一下配置文件 
# virsh define ubuntu10.04.xml 
定義域 ubuntu10.04(從 ubuntu10.04.xml) 
#然后就可以virsh start ubuntu10.04了,不過現在物理網卡這塊還沒有改好 
4,物理網卡可以手動更改,不過現在有現成的工具包,可以用這個更改 
#wget http://www.convirture.com/downloads/convirture-tools/2.0.1/convirture-tools-2.0.1.tar.gz 
# 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.20121128.101114 saved.ifcfg-em3.20121128.101114 
saved.ifcfg-em2.20121128.101114 saved.ifcfg-em4.20121128.101114 
看下ifceg-em1 
# cat ifcfg-em1 
DEVICE="em1" 
#BOOTPROTO=none 
NM_CONTROLLED="yes" 
ONBOOT=yes 
TYPE="Ethernet" 
#UUID="3bc7fdcc-42b1-4223-b202-e697305897c8" 
#IPADDR172.16.10.81 
PREFIX=24 
GATEWAY=172.16.10.254 
DNS1=172.16.10.5 
DEFROUTE=yes 
IPV4_FAILURE_FATAL=yes 
IPV6INIT=no 
NAME="System em1" 
HWADDR=90:B1:1C:20:4D:A5 
BRIDGE=br1 
看下ifcfg-br1 
# cat ifcfg-br1 
DEVICE="br1" 
BOOTPROTO=none 
NM_CONTROLLED="yes" 
ONBOOT=yes 
#UUID="3bc7fdcc-42b1-4223-b202-e697305897c8" 
IPADDR=172.16.10.81 
PREFIX=24 
GATEWAY=172.16.10.254 
DNS1=172.16.10.5 
DEFROUTE=yes 
IPV4_FAILURE_FATAL=yes 
IPV6INIT=no 
NAME="System br1" 
TYPE=Bridge 
最后看下網卡 
# ifconfig 
br1 Link encap:Ethernet HWaddr 90:B1:1C:20:4D:A5 
inet addr:172.16.10.81 Bcast:172.16.10.255 Mask:255.255.255.0 
inet6 addr: fe80::92b1:1cff:fe20:4da5/64 Scope:Link 
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
RX packets:10219 errors:0 dropped:0 overruns:0 frame:0 
TX packets:3776 errors:0 dropped:0 overruns:0 carrier:0 
collisions:0 txqueuelen:0 
RX bytes:576031 (562.5 KiB) TX bytes:15928008 (15.1 MiB) 
em1 Link encap:Ethernet HWaddr 90:B1:1C:20:4D:A5 
inet6 addr: fe80::92b1:1cff:fe20:4da5/64 Scope:Link 
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
RX packets:10362 errors:0 dropped:0 overruns:0 frame:0 
TX packets:13131 errors:0 dropped:0 overruns:0 carrier:0 
collisions:0 txqueuelen:1000 
RX bytes:766684 (748.7 KiB) TX bytes:16489098 (15.7 MiB) 
Interrupt:35 
lo Link encap:Local Loopback 
inet addr:127.0.0.1 Mask:255.0.0.0 
inet6 addr: ::1/128 Scope:Host 
UP LOOPBACK RUNNING MTU:16436 Metric:1 
RX packets:144411 errors:0 dropped:0 overruns:0 frame:0 
TX packets:144411 errors:0 dropped:0 overruns:0 carrier:0 
collisions:0 txqueuelen:0 
RX bytes:147381248 (140.5 MiB) TX bytes:147381248 (140.5 MiB) 
virbr0 Link encap:Ethernet HWaddr 52:54:00:F1:6B:6E 
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
RX packets:2028 errors:0 dropped:0 overruns:0 frame:0 
TX packets:1135 errors:0 dropped:0 overruns:0 carrier:0 
collisions:0 txqueuelen:0 
RX bytes:233311 (227.8 KiB) TX bytes:89372 (87.2 KiB) 
vnet0 Link encap:Ethernet HWaddr FE:54:00:50:58:7E 
inet6 addr: fe80::fc54:ff:fe50:587e/64 Scope:Link 
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
RX packets:161 errors:0 dropped:0 overruns:0 frame:0 
TX packets:3117 errors:0 dropped:0 overruns:0 carrier:0 
collisions:0 txqueuelen:500 
RX bytes:15533 (15.1 KiB) TX bytes:263947 (257.7 KiB) 
vnet1 Link encap:Ethernet HWaddr FE:54:00:B5:1A:19 
inet6 addr: fe80::fc54:ff:feb5:1a19/64 Scope:Link 
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
RX packets:56 errors:0 dropped:0 overruns:0 frame:0 
TX packets:794 errors:0 dropped:0 overruns:0 carrier:0 
collisions:0 txqueuelen:500 
RX bytes:8754 (8.5 KiB) TX bytes:42245 (41.2 KiB) 
5,啟動虛擬機ubuntu10.04后配置網卡 
#cat /etc/network/interface 
auto lo 
iface lo inet loopback 
auto eth0 
iface eth0 inet static 
address 172.16.10.100 
netmask 255.255.255.0 
gateway 172.16.10.254 
#/etc/init.d/networking restart 
啟動即可

延伸 · 閱讀

精彩推薦
  • CentosCentos7運用/dev/shm進行網站優化

    Centos7運用/dev/shm進行網站優化

    這篇文章主要介紹了LINUX中Centos7運用/dev/shm進行網站優化相關知識點,對此有興趣的朋友參考學習下。...

    彬菌9912022-03-02
  • CentosCentos 7開啟網卡自動獲取IP的詳細方法

    Centos 7開啟網卡自動獲取IP的詳細方法

    本篇文章主要介紹了Centos 7開啟網卡自動獲取IP的詳細方法,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧...

    凌鋒8972021-12-29
  • CentosCentOS6.5下Redis安裝與配置詳細步驟

    CentOS6.5下Redis安裝與配置詳細步驟

    本篇文章主要介紹了CentOS6.5下Redis安裝與配置詳細步驟,詳細介紹redis單機單實例安裝與配置,服務及開機自啟動。有興趣的可以了解一下。...

    飛流11452021-12-24
  • Centoscentos 安裝與操作方法

    centos 安裝與操作方法

    這篇文章主要介紹了centos 安裝與操作方法,需要的朋友可以參考下...

    centos之家5272019-07-11
  • CentosCentOS7設置日期和時間方法以及基本概念介紹

    CentOS7設置日期和時間方法以及基本概念介紹

    這篇文章主要介紹了CentOS7設置日期和時間方法以及基本概念介紹,本文講解使用CentOS7中的新命令timedatectl設置日期時間方法,需要的朋友可以參考下 ...

    CentOS之家6522019-09-19
  • CentosCentOS 6.6實現永久修改DNS地址的方法

    CentOS 6.6實現永久修改DNS地址的方法

    這篇文章主要介紹了CentOS 6.6實現永久修改DNS地址的方法,涉及針對CentOS配置文件的相關設置技巧,具有一定參考借鑒價值,需要的朋友可以參考下 ...

    Linux社區4472020-08-21
  • Centoscentos不小心刪除/root目錄該如何解決?

    centos不小心刪除/root目錄該如何解決?

    一些朋友最近在問小編centos不小心刪除/root目錄該如何解決?今天小編就為大家分享centos不小心刪除/root目錄解決辦法;希望對大家會有幫助,有需要的朋友...

    腳本之家8022019-05-29
  • CentosCentOS下Uptime命令詳解

    CentOS下Uptime命令詳解

    在Linux下,我們可以使用uptime命令,而且此命令不必使用root權限。uptime命令在系統中已經默認安裝了。今天小編為大家帶來的是CentOS下Uptime命令詳解;希望...

    CentOS之家11482019-06-19
主站蜘蛛池模板: 欧美亚洲天堂网 | 好男人资源免费播放在线观看 | 国产3p在线| 亚洲第一区欧美日韩精品 | 日日摸夜夜爽色婷婷91 | 国内永久第一免费福利视频 | 亚洲国产在线视频精品 | 亚洲男男video | 日本xxxx19视频 | 好大好猛好爽好深视频免费 | 日本艳鉧动漫1~6完整版在 | 1313午夜精品理伦片 | 成人免费国产欧美日韩你懂的 | 亚洲AV无码A片在线观看蜜桃 | 日韩一级生活片 | 大伊香蕉精品视频一区 | 国产女主播福利在线 | 齐天大性之七仙女欲春迅雷链接 | 久久黄视频 | 黑人巨摘花第一次出血 | 国产日产精品久久久久快鸭 | 精品精品国产自在香蕉网 | 四虎影视在线影院在线观看 | www.精品视频 | 亚欧洲乱码视频一二三区 | 久久久久久久久女黄9999 | 校草太大了h | 99热.com| 四虎成人网| 日本在线视频播放 | 视频一区二区三区在线观看 | 亚洲国产精品无码中文在线 | 亚洲欧美精品久久 | 国产探花在线视频 | 美女撒尿毛片免费看 | 欧美精品1区2区 | 国产精品亚洲片在线观看麻豆 | 亚洲精品国产成人 | 亚洲高清国产拍精品动图 | 白丝爆动漫羞羞动漫网站 | 久久精品一卡二卡三卡四卡视频版 |