@[TOC](openstack 实现内外网络(小节12))
控制端(controller1和controller2)节点(node1和node2)
添加网卡
查看是否有'eth1'网卡
控制端(controller1和controller2)节点(node1和node2)(以node1为例)
网卡配置信息
[root@node1 ~]# cd /etc/sysconfig/network-scripts/
[root@node1 network-scripts]# cp ifcfg-eth0 ifcfg-eth1
[root@node1 network-scripts]# vim ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=static
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=10.20.1.103
PREFIX=21
启动'eth1'网卡、并查看状态
[root@node1 network-scripts]# ifup eth1
[root@node1 network-scripts]# ifconfig eth1
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.20.1.103 netmask 255.255.248.0 broadcast 10.20.7.255
inet6 fe80::20c:29ff:fedd:6494 prefixlen 64 scopeid 0x20<link>
inet6 2408:8207:c04:fb20:20c:29ff:fedd:6494 prefixlen 64 scopeid 0x0<global>
ether 00:0c:29:dd:64:94 txqueuelen 1000 (Ethernet)
RX packets 84 bytes 7991 (7.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 76 bytes 6312 (6.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
控制端controller2
[root@controller2 ~]# vim /etc/neutron/plugins/ml2/ml2_conf.ini
...
[ml2_type_flat]
flat_networks = external,internal <--添加'internal'内网
...
[root@controller2 ~]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
...
[linux_bridge]
physical_interface_mappings = external:eth0,internal:eth1 <--添加'internal'内网对应网卡名称
...
拷贝文件到(控制端controller1)
[root@controller2 ~]# scp /etc/neutron/plugins/ml2/{ml2_conf,linuxbridge_agent}.ini root@10.20.1.101:/etc/neutron/plugins/ml2/
重启服务器
[root@controller2 ~]# reboot
node1
定义网络映射关系
[root@node1 network-scripts]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[linux_bridge]
physical_interface_mappings = external:eth0,internal:eth1 <--
修改计算节点上的nova配置文件,避免创建实例时报无法分配网络的错误
[root@node1 network-scripts]# vim /etc/nova/nova.conf
[DEFAULT]
vif_plugging_is_fatal=false <--
vif_plugging_timeout=0 <--
传到node2
[root@node1 network-scripts]# scp /etc/neutron/plugins/ml2/linuxbridge_agent.ini root@10.20.1.104:/etc/neutron/plugins/ml2/
node2
如果'nova.conf'是通过node1传过来的需要把文件中'server_proxyclient_address = 自己本机IP'
[root@node2 ~]# vim /etc/nova/nova.conf
[DEFAULT]
vif_plugging_is_fatal=false <--
vif_plugging_timeout=0 <--
node1和node2
设置开机启动nova服务
[root@node1 network-scripts]# systemctl enable openstack-nova-compute.service
重启nova服务
[root@node1 network-scripts]# systemctl restart openstack-nova-compute.service
重启服务器
[root@node1 network-scripts]# reboot
controller2
[root@controller2 ~]# source scripts/admin_stein.sh
[root@controller2 ~]# openstack network list
+--------------------------------------+--------------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+--------------+--------------------------------------+
| 8da22e8c-e478-460e-818b-7ea2805e137f | external-net | 7c81426c-7147-44cf-88d7-e794a4a30d08 |
+--------------------------------------+--------------+--------------------------------------+
创建内网 桥接网络、网络名称叫'internal-net'
[root@controller2 ~]# neutron net-create --shared --provider:physical_network internal --provider:network_type flat internal-net
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2022-10-13T04:55:30Z |
| description | |
| id | 85a77e7a-3098-49f3-9bd6-5c8577785598 |
| ipv4_address_scope | |
| ipv6_address_scope | |
| mtu | 1500 |
| name | internal-net |
| port_security_enabled | True |
| project_id | c26c5975bb5a4519a7894f3191b0b425 |
| provider:network_type | flat |
| provider:physical_network | internal |
| provider:segmentation_id | |
| revision_number | 1 |
| router:external | False |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| tenant_id | c26c5975bb5a4519a7894f3191b0b425 |
| updated_at | 2022-10-13T04:55:30Z |
+---------------------------+--------------------------------------+
创建子网
[root@controller2 ~]# neutron subnet-create --name internal-sub --allocation-pool start=10.20.1.1,end=10.20.1.254 --dns-nameserver 223.5.5.5 internal-net 10.20.0.0/21
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
Created a new subnet:
+-------------------+----------------------------------------------+
| Field | Value |
+-------------------+----------------------------------------------+
| allocation_pools | {"start": "10.20.1.1", "end": "10.20.1.254"} |
| cidr | 10.20.0.0/21 |
| created_at | 2022-10-13T05:02:10Z |
| description | |
| dns_nameservers | 223.5.5.5 |
| enable_dhcp | True |
| gateway_ip | 10.20.0.1 |
| host_routes | |
| id | 453aa777-2edd-4399-bad9-9f849f41a418 |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | internal-sub |
| network_id | 85a77e7a-3098-49f3-9bd6-5c8577785598 |
| project_id | c26c5975bb5a4519a7894f3191b0b425 |
| revision_number | 0 |
| service_types | |
| subnetpool_id | |
| tags | |
| tenant_id | c26c5975bb5a4519a7894f3191b0b425 |
| updated_at | 2022-10-13T05:02:10Z |
+-------------------+----------------------------------------------+
查看网络列表,包括内网与外网
[root@controller2 ~]# openstack network list
+--------------------------------------+--------------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+--------------+--------------------------------------+
| 85a77e7a-3098-49f3-9bd6-5c8577785598 | internal-net | 453aa777-2edd-4399-bad9-9f849f41a418 | <--内网
| 8da22e8c-e478-460e-818b-7ea2805e137f | external-net | 7c81426c-7147-44cf-88d7-e794a4a30d08 | <--外网
+--------------------------------------+--------------+--------------------------------------+
查看子网列表,包括内网子网与外网子网
[root@controller2 ~]# openstack subnet list
+--------------------------------------+---------------+--------------------------------------+-----------------+
| ID | Name | Network | Subnet |
+--------------------------------------+---------------+--------------------------------------+-----------------+
| 453aa777-2edd-4399-bad9-9f849f41a418 | interbak-sub | 85a77e7a-3098-49f3-9bd6-5c8577785598 | 10.20.0.0/21 |
| 7c81426c-7147-44cf-88d7-e794a4a30d08 | external-sub | 8da22e8c-e478-460e-818b-7ea2805e137f | 192.168.32.0/21 |
+--------------------------------------+---------------+--------------------------------------+-----------------+
node1和node2
列出正在运行的虚拟机