kvm桥接

为了以防万一,先把eth0的配置备份:

 #  mkdir backup
 #  cp ifcfg-eth0 backup/


创建br0配置文件:

#vim ifcfg-br0

DEVICE=br0
BOOTPROTO=none
ONBOOT=yes
TYPE=Bridge
IPADDR=110.65.97.227
PREFIX=22
GATEWAY=110.65.96.1
DNS1=202.192.72.33
DNS2=8.8.8.8

这是eth0的原配置文件:

#cat ifcfg-eth0

DEVICE=eth0
HWADDR=B8:70:F4:40:8A:20
TYPE=Ethernet
UUID=bee6af6c-4e20-4d28-81cd-8870b9d40ea9
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=110.65.97.227
PREFIX=22
GATEWAY=110.65.96.1
DNS1=202.192.72.33
DNS2=8.8.8.8

修改eth0的配置文件:

DEVICE=eth0
#HWADDR=B8:70:F4:40:8A:20
TYPE=Ethernet
#UUID=bee6af6c-4e20-4d28-81cd-8870b9d40ea9
ONBOOT=yes
NM_CONTROLLED=none
BOOTPROTO=none
#IPADDR=110.65.97.227
#PREFIX=22
#GATEWAY=110.65.96.1
#DNS1=202.192.72.33
#DNS2=8.8.8.8
BRIDGE=br0

尝试重启network服务:

[root@zsmin network-scripts]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Error: Connection activation failed: Master connection not found or invalid
                                                          [FAILED]
Bringing up interface wlan0:  Error: No suitable device found: no device found for connection 'wlan0'.
                                                          [FAILED]
Bringing up interface br0:  Error: Connection activation failed: Failed to determine connection's virtual interface name
                                                          [FAILED]


报错了。


这个需要我们关闭NetworkManager

#service NetworkManager stop

#chkconfig NetworkManager off


这时候,右上角的两台小电脑就会不见了。


再一次重启服务:

# service network restart
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
Bringing up interface wlan0:  Device does not seem to be present, delaying initialization.
                                                          [FAILED]
Bringing up interface br0:  Determining if ip address 110.65.97.227 is already in use for device br0...
                                                          [  OK  ]


[root@zsmin network-scripts]# ifconfig br0
br0       Link encap:Ethernet  HWaddr B8:70:F4:40:8A:20  
         inet addr:24.155.108.210  Bcast:24.255.255.255  Mask:255.0.0.0
         inet6 addr: 2001:da8:2006:a438:ba70:f4ff:fe40:8a20/64 Scope:Global
         inet6 addr: fe80::ba70:f4ff:fe40:8a20/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:20050 errors:0 dropped:0 overruns:0 frame:0
         TX packets:1058 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:2169121 (2.0 MiB)  TX bytes:245674 (239.9 KiB)
[root@zsmin network-scripts]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr B8:70:F4:40:8A:20  
         inet6 addr: fe80::ba70:f4ff:fe40:8a20/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:145869 errors:0 dropped:0 overruns:0 frame:0
         TX packets:13314 errors:0 dropped:0 overruns:0 carrier:1
         collisions:0 txqueuelen:1000
         RX bytes:24030233 (22.9 MiB)  TX bytes:1933211 (1.8 MiB)

[root@zsmin network-scripts]# ping www.google.com
PING www.google.com (74.125.128.103) 56(84) bytes of data.
64 bytes from hg-in-f103.1e100.net (74.125.128.103): icmp_seq=1 ttl=38 time=96.3 ms
64 bytes from hg-in-f103.1e100.net (74.125.128.103): icmp_seq=2 ttl=38 time=96.1 ms
^C
--- www.google.com ping statistics ---
3 packets transmitted, 2 received, 33% packet loss, time 2031ms
rtt min/avg/max/mdev = 96.103/96.231/96.360/0.335 ms

之后,kvm虚拟机里面网卡设置就会出现br0了。

你可能感兴趣的:(kvm,配置文件,桥接)