KVM基础3

2021-12-03 20:40:27 浏览数 (1)


创建网桥

为了和宿主机有平等的网络层级 (能使用到上面的dhcp),可以通过构建网桥的办法来实现

配置

代码语言:javascript复制
[root@kvm-demo network-scripts]# grep -v "^#" ifcfg-eth0 


DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BRIDGE=br0
[root@kvm-demo network-scripts]# grep -v "^#" ifcfg-br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.234
NETMASK=255.255.255.0
GATEWAY=192.168.1.2
[root@kvm-demo network-scripts]# 

重启网络

为了使配置生效,得重启网络

代码语言:javascript复制
[root@kvm-demo network-scripts]# /etc/init.d/network restart ; ifup br0 
Shutting down interface br0:                               [  OK  ]
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface br0:  Device br0 does not seem to be present, delaying initialization.
                                                           [FAILED]
Bringing up interface eth0:                                [  OK  ]
Determining if ip address 192.168.1.234 is already in use for device br0...
[root@kvm-demo network-scripts]# 

Note: 最好使用 /etc/init.d/network restart ; ifup br0 , 因为并不一定重启网络会带着 br0 一起重启,如果是远程操作,这个时候就有很大的风险与主机失联,这时原网卡没有配置ip,br0又没启动,会产生很大的麻烦,只能去机房通过服务器的console进行恢复

0 人点赞