一、在VMware上打开DHCP功能
image.png
image.png
二、创建桥接网卡
virsh iface-bridge eth0 br0
image.png
三、创建虚拟桥接磁盘
qemu-img create -f qcow2 -b web01.qcow2 bridge.qcow2
image.png
四、创建桥接模式虚拟机bridge
virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name bridge --memory 1024 --vcpus 1 --disk /data/bridge.qcow2 --boot hd --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole
image.png
五、检查虚拟机运行状态
[root@kvm01 ~]# virsh list
Id 名称 状态
----------------------------------------------------
1 bridge running
2 web-nginx running
六、使用VNC-Viewer客户端远程连接工具登录虚拟机,查看ip
image.png
七、在宿主机上连接10.0.0.128虚拟机(测试)
[root@kvm01 ~]# ssh root@10.0.0.128
root@10.0.0.128's password:
Last login: Tue Jul 16 12:24:47 2019 from 10.0.0.10
[root@zwb ~]# lscpu |grep -i 'kvm'
超管理器厂商: KVM
[root@zwb ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:3f:5c:a0 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.128/24 brd 10.0.0.255 scope global dynamic eth0
valid_lft 1249sec preferred_lft 1249sec
inet6 fe80::5054:ff:fe3f:5ca0/64 scope link
valid_lft forever preferred_lft forever
八、网络报错解决:
image.png
1.
echo 'DEVICE=eth0
ONBOOT=yes
BRIDGE="br0"' >/etc/sysconfig/network-scripts/ifcfg-eth0
2.
echo 'DEVICE="br0"
ONBOOT="yes"
TYPE="Bridge"
BOOTPROTO="none"
IPADDR="10.0.0.10"
NETMASK="255.255.255.0"
GATEWAY="10.0.0.254"
STP="on"
DELAY="0"' >/etc/sysconfig/network-scripts/ifcfg-br0
网友评论