问题描述:虚拟机ubuntu16.04安装完openstack重启后,实例不能连接外网,虚拟机有网络。
参考:https://blog.csdn.net/Jmilk/article/details/89850079
通过ovs-vsclt查看
发现是通过br-ex连接外网,因此将虚拟机网络设置在和br-ex同一个网段下应该就可以了,通过实际验证发现这种方法可行。
解决:
1.首先通过控制台查看openstack的外部网络地址段是什么。
如同我的网段是172.24.4.0/24
2.配置虚拟机的网段为172.24.4.0。
虚拟机编辑-->虚拟网络编辑器--->更改设置
设置子网IP为172.24.4.0,配置VMnet8--->NAT设置
如图设置网关为172.24.4.2(此处不能和物理机冲突,如果物理机为172.24.4.4就不能设置为172.24.4.1)
3.执行一下命令
sudo ifconfig ens33 0.0.0.0; (此处应该为你的网卡,不同机器网卡名称不一致 可以通过ifconfig命令查看网卡名称)
sudo ovs-vsctl add-port br-ex ens33;(将ens33 绑定到网桥br-ex 上)
sudo ifconfig br-ex 172.24.4.3/24;
sudo route add default gw 172.24.4.2(应该与上面设置的网关一致)
如图正确配置应该如图
执行 route 命令
执行ovs-vsctl
(tflearn) root@computer3:/home/hao/Desktop/project# ovs-vsctl show
8c0a1bee-c3cf-41a7-9a20-56b041c5bf83
Manager "ptcp:6640:127.0.0.1"
is_connected: true
Bridge br-ex
Controller "tcp:127.0.0.1:6633"
is_connected: true
fail_mode: secure
Port phy-br-ex
Interface phy-br-ex
type: patch
options: {peer=int-br-ex}
Port br-ex
Interface br-ex
type: internal
Port "ens33"
Interface "ens33"
Port "eth0"
Interface "eth0"
error: "could not open network device eth0 (No such device)"
Bridge br-int
Controller "tcp:127.0.0.1:6633"
is_connected: true
fail_mode: secure
Port "tap10ea2523-c4"
tag: 1
Interface "tap10ea2523-c4"
type: internal
Port "tap13c3a01f-6a"
tag: 1
Interface "tap13c3a01f-6a"
error: "could not open network device tap13c3a01f-6a (No such device)"
Port int-br-ex
Interface int-br-ex
type: patch
options: {peer=phy-br-ex}
Port "qg-a167ca8d-10"
tag: 2
Interface "qg-a167ca8d-10"
type: internal
Port "qr-784306ff-1b"
tag: 1
Interface "qr-784306ff-1b"
type: internal
Port br-int
Interface br-int
type: internal
Port "tap72bf64cc-1b"
tag: 1
Interface "tap72bf64cc-1b"
Port patch-tun
Interface patch-tun
type: patch
options: {peer=patch-int}
Bridge br-tun
Controller "tcp:127.0.0.1:6633"
is_connected: true
fail_mode: secure
Port br-tun
Interface br-tun
type: internal
Port patch-int
Interface patch-int
type: patch
options: {peer=patch-tun}
ovs_version: "2.9.0"
(tflearn) root@computer3:/home/hao/Desktop/project#