028-实现阿里云ESC多FLAT网络
实现类似于阿里云ECS的网络结构,其效果为云主机拥有两块和两个不同的网络,一个网络是用于用于和外网连接,一个用于内网通信,但宿主机上至少有两个网卡,整体配置如下:
1.在wmare里给宿主机添加一块网卡,模式为仅主机,网段为192.168.2.0/24 模拟外网地址,原ip 192.168.1.0/24 模拟内网地址,其实应该 可以上网的 192.168.1.0/24 为外网地址,但这里模拟,所以无所谓
创建新加网卡的配置文件ens37
[root@linux-node2 ~]# cd /etc/sysconfig/network-scripts/
[root@linux-node2 network-scripts]# cp ifcfg-ens33 ifcfg-ens37
[root@linux-node2 network-scripts]# vim ifcfg-ens37
[root@linux-node2 network-scripts]# cat ifcfg-ens37
TYPE="Ethernet"
BOOTPROTO="none"
DEVICE="ens37"
ONBOOT="yes"
IPADDR="192.168.2.231"
PREFIX="24"
#GATEWAY="192.168.1.100" 不需要网关,因为这是仅主机模式的测试环境,生产环境一定要有网关
linux-node1 同上操作
但目前的网络有点问题,ip a 发现ens33和brqecad9a89-d0都有IP 修改完配置文件重启neutron 后就好了
linux-node1上操作:
vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
physical_interface_mappings = physnet1:ens33,internal:ens37 # #这是一个列表,新添加一个网卡映射关系
source admin-openstack
openstack endpoint list
vim /etc/neutron/plugins/ml2/ml2_conf.ini
flat_network:单一扁平网络
flat_network = physnet1,internal ##调用上面的映射关系
systemctl restart neutron-server
systemctl restart neutron-linuxbridge-agent
vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
physical_interface_mappings = physnet1:ens33,internal:ens37
[root@linux-node2 ~]# systemctl restart neutron-linuxbridge-agent
[root@linux-node1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master brqecad9a89-d0 state UP group default qlen 1000
link/ether 00:0c:29:d1:eb:67 brd ff:ff:ff:ff:ff:ff
inet6 fe80::20c:29ff:fed1:eb67/64 scope link
valid_lft forever preferred_lft forever
3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:d1:eb:71 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.230/24 brd 192.168.2.255 scope global ens37
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fed1:eb71/64 scope link
valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:7c:7b:42 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:7c:7b:42 brd ff:ff:ff:ff:ff:ff
6: tap676e4377-48@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master brqecad9a89-d0 state UP group default qlen 1000
link/ether a6:54:b8:79:c8:2e brd ff:ff:ff:ff:ff:ff link-netnsid 0
7: brqecad9a89-d0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:0c:29:d1:eb:67 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.230/24 brd 192.168.1.255 scope global brqecad9a89-d0
valid_lft forever preferred_lft forever
inet6 fe80::88f6:e4ff:fea4:e517/64 scope link
valid_lft forever preferred_lft forever
[root@linux-node2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:56:29:54 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.231/24 brd 192.168.1.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe56:2954/64 scope link
valid_lft forever preferred_lft forever
3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:56:29:5e brd ff:ff:ff:ff:ff:ff
inet 192.168.2.231/24 brd 192.168.2.255 scope global ens37
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe56:295e/64 scope link
valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:a1:7e:7f brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:a1:7e:7f brd ff:ff:ff:ff:ff:ff
6: brqecad9a89-d0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
link/ether 0a:e1:50:84:a1:42 brd ff:ff:ff:ff:ff:ff
如上硬重启虚拟机2节点IP就会正常
openstack network create --share \
--provider-physical-network internal \
--provider-network-type flat internal <--网络名称
openstack subnet create --network internal \
--allocation-pool start=192.168.2.240,end=192.168.2.251 \
--dns-nameserver 192.168.1.100 --gateway 192.168.2.100 \
--subnet-range 192.168.2.0/24 internal-subnet
查看是否创建成功
neutron net-list
创建个新的云主机,添加两个网络,先加公网和先加内网是不一样的,创建虚拟机,在网络选择步骤选择两个网络,循序为那个网络是第一个哪个就是eth0:
-
dashboard查看并创建云主机
在创建云主机时即可选择网络,如图:
实现阿里云的FLAT网络(经典网络)一个公网ip,一个私网ip,如图:
VNC查看: