Set the network card to bridge mode under CentOS6.3 KVM
The default network mode of KVM is NAT, which means to use the [Host] (https://cloud.tencent.com/product/cdh?from=10680) mode to access the Internet. Now we want to change to the bridge mode so that the outside world can directly communicate with the host
The virtual machine is communicating.
1 , First look at the default network settings
< network>
< /network>
2 , Look at the network settings in the virtual machine configuration file
< domain type='kvm'>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
3 , Update the configuration file after changing
Definition domain ubuntu10.04 (from ubuntu10.04.xml)
4 , The physical network card can be changed manually, but now there is a ready-made toolkit, you can use this to change
There is a small problem here, I found that the network is not up, so do not do this operation remotely, the main reason is that the configuration file inside is a bit needed
Minor changes, mine is UUID annotation.
ifcfg-br1 ifcfg-br2 ifcfg-br3 ifcfg-br4 ifcfg-em1 ifcfg-em2 ifcfg-em3 ifcfg-em4 ifcfg-lo
I have four physical network cards here, so four bridges are generated, but only br1 is actually used
One advantage of this tool is that it saves the original configuration file, and you can restore it if you don’t want to use it.
saved.ifcfg-em1.20121128.101114 saved.ifcfg-em3.20121128.101114
saved.ifcfg-em2.20121128.101114 saved.ifcfg-em4.20121128.101114
Take a look at ifceg-em1
DEVICE="em1"
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE="Ethernet"
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
Take a look at ifcfg-br1
DEVICE="br1"
BOOTPROTO=none
NM_CONTROLLED="yes"
ONBOOT=yes
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
Finally look at the network card
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, Configure the network card after starting the virtual machine ubuntu10.04
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
Just start
Recommended Posts