|NO.Z.00021|——————————|^^^^ 部署 ^^^^|——|OpenStack&组件.V08|——|OpenStack-network|Network创建租户网络.V04|

一、配置租户网络(在controller节点执行后面的命令)
### --- 配置租户网络(在controller节点执行后面的命令)

~~~     创建租户网络
~~~     创建租户网络的子网
~~~     在租户网络创建一个路由器,用来连接外部我那个和租户网
二、创建一个租户网络
### --- 执行demo环境变量脚本

[root@controller ~]# source demo-openrc.sh 
### --- 创建租户网络

[root@controller ~]# neutron net-create demo-net
Created a new network:
+-----------------+--------------------------------------+
| Field           | Value                                |
+-----------------+--------------------------------------+
| admin_state_up  | True                                 |
| id              | 594c06f8-09a3-4d37-b5aa-a6f250356332 |
| name            | demo-net                             |
| router:external | False                                |
| shared          | False                                |
| status          | ACTIVE                               |
| subnets         |                                      |
| tenant_id       | 5f158b7cfb7448d18921158f9c92918f     |
+-----------------+--------------------------------------+
三、创建一个租户网络的子网
### --- 创建子网
~~~     TENANT_NETWORK_GATEWAY=租户网的网关
~~~     TENANT_NETWORK_CIDR=租户网的网段
~~~     这个子网就可以随便分配了,只要和之前创建的网段不要冲突就可以了

neutron subnet-create demo-net --name demo-subnet \
--gateway TENANT_NETWORK_GATEWAY  TENANT_NETWORK_CIDR
### --- 例如,租户网的网段为192.168.2.0/24,网关为192.168.2.1(网关通常默认为,1)

[root@controller ~]# neutron subnet-create demo-net --name demo-subnet \
> --gateway 192.168.2.1 192.168.2.0/24
Created a new subnet:
+-------------------+--------------------------------------------------+
| Field             | Value                                            |
+-------------------+--------------------------------------------------+
| allocation_pools  | {"start": "192.168.2.2", "end": "192.168.2.254"} |
| cidr              | 192.168.2.0/24                                   |
| dns_nameservers   |                                                  |
| enable_dhcp       | True                                             |
| gateway_ip        | 192.168.2.1                                      |
| host_routes       |                                                  |
| id                | 33b3861c-9dfc-4768-b226-ccd5e85577f9             |
| ip_version        | 4                                                |
| ipv6_address_mode |                                                  |
| ipv6_ra_mode      |                                                  |
| name              | demo-subnet                                      |
| network_id        | 594c06f8-09a3-4d37-b5aa-a6f250356332             |
| tenant_id         | 5f158b7cfb7448d18921158f9c92918f                 |
+-------------------+--------------------------------------------------+
四、在租户网络创建一个路由器,用来连接外部网和租户网
### --- 创建路由器

[root@controller ~]# neutron router-create demo-router
Created a new router:
+-----------------------+--------------------------------------+
| Field                 | Value                                |
+-----------------------+--------------------------------------+
| admin_state_up        | True                                 |
| external_gateway_info |                                      |
| id                    | 211ed5ae-7c05-44ca-9fc4-be68348cb44b |
| name                  | demo-router                          |
| routes                |                                      |
| status                | ACTIVE                               |
| tenant_id             | 5f158b7cfb7448d18921158f9c92918f     |
+-----------------------+--------------------------------------+
### --- 附加路由器到demo租户的子网:路由网卡添加,添加一个subnet的网络

[root@controller ~]# neutron router-interface-add demo-router demo-subnet
Added interface 4d8bd260-1795-46b8-b61f-e2fb889d601e to router demo-router.
### --- 通过设置网关,使路由器附加到外部网:
~~~     通过设置网关的方式,网关为ext-net,也就是我们的浮动网络

[root@controller ~]# neutron router-gateway-set demo-router ext-net
Set gateway for router demo-router
五、确认连接
### --- 查看路由器获取到的IP:
~~~     这个路由上分配了一个IP地址是100.100.100.12
~~~     在物理本地笔记本上打开网络配置VMnet3,
~~~     修改IPV4的地址Wie100.100.100.240和这个网段相互匹配

[root@controller ~]# neutron router-list
+--------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                                   | name        | external_gateway_info                                                                                                                                                                     |
+--------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 211ed5ae-7c05-44ca-9fc4-be68348cb44b | demo-router | {"network_id": "128ca157-22e0-4ef1-86af-c326e510ef89", "enable_snat": true, "external_fixed_ips": [{"subnet_id": "d81339e0-4025454c-b858-0815d2730255", "ip_address": "100.100.100.12"}]} |
+--------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
### --- 在任何一台外部主机上ping路由器获取到的外部地址
~~~     通过cmd窗口ping 100.100.100.12是否ping通;
~~~     也就说明通过外部网络可以访问到路由器了,network节点配置完成。

C:\Users\Administrator>ping 100.100.100.12
正在 Ping 100.100.100.12 具有 32 字节的数据:
来自 100.100.100.12 的回复: 字节=32 时间=1ms TTL=64
来自 100.100.100.12 的回复: 字节=32 时间<1ms TTL=64
来自 100.100.100.12 的回复: 字节=32 时间<1ms TTL=64
来自 100.100.100.12 的回复: 字节=32 时间<1ms TTL=64

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(27)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示