Devstack local.conf

# Note: please change XX to your devstack node IP, change VLAN_START and VLAN_ENDto your reserved vlan range Here

# 我的IP是192.168.1.46, 所在网络是192.168.1.0/24

[[local|localrc]]

# Set API endpoint host using HOST_IP

HOST_IP=XX

# Use to specify the endpoint

SERVICE_HOST=XX

ADMIN_PASSWORD=welcome

MYSQL_PASSWORD=welcome

RABBIT_PASSWORD=welcome

SERVICE_PASSWORD=welcome

SERVICE_TOKEN=welcome

disable_service h-eng

disable_service h-api

disable_service h-api-cfn

disable_service h-api-cw

disable_service tempest

#enable_service tempest

disable_service dstat

# Enable Neturon

disable_service n-net

enable_service q-svc

enable_service q-agt

enable_service q-dhcp

enable_service q-l3

enable_service q-meta

enable_service neutron

# stack.sh will freshen each repo on each run ifRECLONE

# is set to yes

RECLONE=True

# Setting OFFLINE=True to enable stack.shto run multiple

# times without an Internet connection

OFFLINE=False

# Set FLAT_INTERFACE to the Ethernet interface that connects

# the host to your local network

FLAT_INTERFACE=eth1

#FLOATING_RANGE=192.168.1.0/24#Q_FLOATING_ALLOCATION_POOL=start=192.168.1.100,end=192.168.1.119#PUBLIC_NETWORK_GATEWAY=192.168.1.30PUBLIC_INTERFACE=eth0

PHYSICAL_NETWORK=public_eth1

OVS_PHYSICAL_BRIDGE=br-ex

#PUBLIC_BRIDGE=br-ex

FIXED_RANGE=192.168.100.0/24#FIXED_NETWORK_SIZE=32NETWORK_GATEWAY=192.168.100.1# IMAGE_URLS accepts a comma separated list of images to pre-load into OpenStack

IMAGE_URLS=http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

[[post-config|$NOVA_CONF]]

[DEFAULT]

rpc_response_timeout=300service_down_time=300libvirt_iscsi_use_multipath=True

#force_config_drive=False

[libvirt]

iscsi_use_multipath=True

[database]

max_pool_size=40max_overflow=60[[post-config|/$Q_PLUGIN_CONF_FILE]]

[ml2]

tenant_network_types=vlan,flat

[ml2_type_flat]

flat_networks=public_eth0

[ml2_type_vlan]

network_vlan_ranges=public_eth1:VLAN_START:VLAN_END

[ovs]

bridge_mappings= public_eth0:br-ex,public_eth1:br-eth1

enable_tunneling= False

Setup flat and vlan network​

接下来,我要做两件事,一个是创建一个VLAN ID为100的private network,以后的虚拟机默认是从这个网络分配IP的。

然后是一个flat的public network,这个网络上是用来分配floating IP

创建private network,VLAN ID为100

stack@openstack-wangp11-01:~/devstack$ neutron net-create --provider:network_type vlan --provider:physical_network public_eth1 --provider:segmentation_id 100vlan_100​

stack@openstack-wangp11-01:~/devstack$ neutron net-show vlan_100+---------------------------+--------------------------------------+

| Field | Value |

+---------------------------+--------------------------------------+

| admin_state_up | True |

| id | 2426ff0d-953f-467f-a564-c4f63d926836 |

| mtu | 0 |

| name | vlan_100 |

| port_security_enabled | True |

| provider:network_type | vlan |

| provider:physical_network | public_eth1 |

| provider:segmentation_id | 100 |

| router:external | False |

| shared | False |

| status | ACTIVE |

| subnets | fab94e2f-f7de-4bf6-8e9b-7ade0fcfad1f |

| tenant_id | 8cb8c084ffb84914b41d5044ecbcad4e |

+---------------------------+--------------------------------------+stack@openstack-wangp11-01:~/devstack$ neutron subnet-create --enable-dhcp --ip-version 4 --name vlan_100_subnet01 2426ff0d-953f-467f-a564-c4f63d926836 192.168.46.0/24​

stack@openstack-wangp11-01:~/devstack$ neutron subnet-show fab94e2f-f7de-4bf6-8e9b-7ade0fcfad1f+-------------------+----------------------------------------------------+

| Field | Value |

+-------------------+----------------------------------------------------+

| allocation_pools | {"start": "192.168.46.2", "end": "192.168.46.254"} |

| cidr | 192.168.46.0/24 |

| dns_nameservers | |

| enable_dhcp | True |

| gateway_ip | 192.168.46.1 |

| host_routes | |

| id | fab94e2f-f7de-4bf6-8e9b-7ade0fcfad1f |

| ip_version | 4 |

| ipv6_address_mode | |

| ipv6_ra_mode | |

| name | vlan_100_subnet01 |

| network_id | 2426ff0d-953f-467f-a564-c4f63d926836 |

| subnetpool_id | |

| tenant_id | 8cb8c084ffb84914b41d5044ecbcad4e |

+-------------------+----------------------------------------------------+

接下来,创建Floating IP所在的public network, 网络类型是flat

注意下面:192.168.1.100-192.168.1.119是网络管理员分配给我的IP pool,192.168.1.30是我们网络的router ip

# Step 1: create external flat network

$ neutron net-create --router:external --provider:network_type flat --provider:physical_network public_eth0 public_net

# Step2: create subnet based on your reservation Here

$ neutron subnet-create --name public_eth0_subnet01 --allocation-pool start=192.168.1.100,end=192.168.1.119 --gateway​ 192.168.1.30 --disable-dhcp --ip-version 4 22d01ce7-b4c4-4af2-bc3c-9c3991903b4c 192.168.1.0/24# Step3: create a external router

$ neutron router-create router1

# Step4: connect router1 with the private subnet via 'neutron router-interface-add '$ neutron router-interface-add 2da62299-6e41-4b24-a1c7-a3d6cc4db1c8 fab94e2f-f7de-4bf6-8e9b-7ade0fcfad1f

# Step5: Set the external public network as the router gateway 'neutron router-gateway-set '$ neutron router-gateway-set 73a38db4-20f9-49ba-b855-472be1e2fd45 e0368da6-197e-4c46-bfd1-4897d61b519a

# Step6: Create floating IP from public network 'neutron floatingip-create '$ neutron floatingip-create 1452712a-acb3-4341-a5ca-1d838eb2feb9

# Step7: assicate the VM instance's port in private network to the newly created floating ip port

## get the port id of floating IP (inbold)

$ stack@openstack-wangp11-01:~$ neutron floatingip-list+--------------------------------------+------------------+---------------------+--------------------------------------+

| id | fixed_ip_address | floating_ip_address | port_id |

+--------------------------------------+------------------+---------------------+--------------------------------------+

| a2316e0b-6d72-420f-8a23-f8421160d3d4 | | 192.168.1.102 | 75353e16-5a16-452e-b420-0ada719d625c |

+--------------------------------------+------------------+---------------------+--------------------------------------+## get the portidof private interface attached to VM instance

$ stack@openstack-wangp11-01:~$ neutron port-list+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+

| id | name | mac_address | fixed_ips |

+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+

| 16a3e39c-48ef-4d4d-bc8a-96b27da7ff3c | | fa:16:3e:c1:24:51 | {"subnet_id": "e0368da6-197e-4c46-bfd1-4897d61b519a", "ip_address": "192.168.1.100"} |

| 616d03cd-df6a-465f-a23a-b6bf46e55f7a | | fa:16:3e:48:2e:7f | {"subnet_id": "fab94e2f-f7de-4bf6-8e9b-7ade0fcfad1f", "ip_address": "192.168.46.4"} |

| 713e4541-7d22-4403-b828-94d714d94ec0 | | fa:16:3e:af:43:7b | {"subnet_id": "fab94e2f-f7de-4bf6-8e9b-7ade0fcfad1f", "ip_address": "192.168.46.2"} |

| 75353e16-5a16-452e-b420-0ada719d625c | | fa:16:3e:23:11:db | {"subnet_id": "fab94e2f-f7de-4bf6-8e9b-7ade0fcfad1f", "ip_address": "192.168.46.3"}

# 上面红色的port是VM在private network的interface

$ stack@openstack-wangp11-01:~$ neutron floatingip-associate a2316e0b-6d72-420f-8a23-f8421160d3d4 75353e16-5a16-452e-b420-0ada719d625c

# Now you can use'192.168.1.102' to login to the VM instance from 192.168.1.XX network

我在最前面提到,这个Floating IP是通过namespace内的iptables规则实现的,如何查看呢?下面是在neutron node上的一个实例,192.168.1.102是Floating IP,192.168.46.3是private IP

ip netns exec qrouter- iptables -t nat -S-A quantum-l3-agent-OUTPUT -d 192.168.1.102/32 -j DNAT --to-destination 192.168.46.3

-A quantum-l3-agent-PREROUTING -d 192.168.1.102/32 -j DNAT --to-destination 192.168.46.3

-A quantum-l3-agent-float-snat -s 192.168.46.3/32 -j SNAT --to-source 192.168.1.102

启用nameserver

现在,VM跟外界可以通过192.168.1.102进行通信了,在外界看来,VM的Ip就是192.168.1.102了,但是有一个问题,无法访问网站,也无法sudo apt-get update

必须要启用nameserver才可以访问外面的网址

# add following to /etc/resolv.conf of the VM instance to enable name service

nameservernameserver#and run following to enable

sudo resolvconf-u

问题诊断

TODO

linux floating ip,Floating IP in OpenStack Neutron相关推荐

  1. linux操作系统-设置静态ip

    在使用linux虚拟机的时候因为经常有关机的需求,然后重新开机后可能面临这上一次获取的ip被改变,在这里我分享一下在linux 下设置静态ip的经验 1.查看路由状态 [root@localhost ...

  2. 3.请执行命令取出linux中eth0的IP地址(考试题答案系列)

    说明:本文为老男孩linux培训某节课前考试试题及答案分享博文内容的一部分,也是独立成题的,你可以点下面地址查看全部的内容信息.http://oldboy.blog.51cto.com/2561410 ...

  3. Linux 中ifconfig和ip addr命令查看不到ip解决方法

    Linux 中ifconfig和ip addr命令查看不到ip解决方法 参考文章: (1)Linux 中ifconfig和ip addr命令查看不到ip解决方法 (2)https://www.cnbl ...

  4. Linux网络编程之IP地址转换为无符号整数的方法

    Linux网络编程之IP地址转换为无符号整数的方法,代码如下:(没考虑异常输入) #include <stdio.h> #include <string.h> #include ...

  5. linux系统修改bond的ip,Linux下快速设定ip bond,linux设定ipbond

    Linux下快速设定ip bond,linux设定ipbond 在计算机网路普及的初期,很多OS系统都使用的为单网卡方式,即一个网卡使用一个IP地址.随着网络要求的不断提高,我们可以对多个网卡进行绑定 ...

  6. linux shell 域名 ip,Shell脚本一种检查Linux中域名和IP地址所有权信息、检查多个域名的到期日期工具...

    Shell脚本一种检查Linux中域名和IP地址所有权信息.检查多个域名的到期日期工具 jwhois是一个命令行实用程序,可从whois服务器(whois数据库)中获取有关域名所有权的信息. Whoi ...

  7. Linux 指令简单将***IP列入iptables 限制范围

    Linux 指令简单将***IP列入iptables 限制范围 今天部分服务器收到真IP的非SYN***,郁闷. netstat -an | grep -v LISTEN | awk '{print ...

  8. linux 时间 无法连接服务器地址,怎么解决linux访问不了ip地址问题?

    怎么解决linux访问不了ip地址问题? 发布时间:2020-05-27 18:00:56 来源:亿速云 阅读:291 作者:Leah 解决方法如下: 1.编辑/etc/sysconfig/iptab ...

  9. linux下IPROTO_TCP,TCP/IP协议栈在Linux内核中的运行时序分析

    可选题目三:TCP/IP协议栈在Linux内核中的运行时序分析 在深入理解Linux内核任务调度(中断处理.softirg.tasklet.wq.内核线程等)机制的基础上,分析梳理send和recv过 ...

  10. Linux环境下查看IP不显示IPv4地址

    Linux环境下查看IP不显示IPv4地址 问题 解决方法 额外方法 后续 问题 这篇文章记录一下,当我在虚拟机下运行Ubuntu时,想在我的windows下通过putty连接到Linux系统,但发现 ...

最新文章

  1. .exe已停止工作_这几天我遇到了前所未有的问题windows10 1809 explorer.exe资源管理器频繁崩溃...
  2. python 异常操作 处理方法
  3. 【AOP 面向切面编程】Android Studio 中配置 AspectJ ( 下载并配置AS中 jar 包 | 配置 Gradle 和 Gradle 插件版本 | 配置 Gradle 构建脚本 )
  4. linux java连接redis_java 连接linux的redis 报错。但是linux 客户端可以连接redis
  5. java 人脸检测_Java+OpenCV实现人脸检测并自动拍照
  6. BZOJ #3625 CF #438E 小朋友和二叉树
  7. 如何让自己的内心强大起来
  8. Redis(五):List集合数据类型详解
  9. 对某公司一次***测试
  10. 线性代数【14】线性变换 linear transformation
  11. 如何在Mac上使用Memoji贴纸、屏幕效果、应用程序和Messages
  12. VRTK实现瞬移, 多场景复制
  13. 澳大利亚域名_AU域名,澳大利亚域名,注册AU域名,au域名注册
  14. 利用PCL库做简单的三维立体图形
  15. google黑客常用搜索语句
  16. 04.jQuery++1201
  17. c/c++算法之“24点”经典问题
  18. Promise的基础使用与生成器配合Promise解决回调地狱
  19. iar使用:创建工程
  20. 怎样设定绩效考核指标

热门文章

  1. 自然语言处理(NLP)之英文单词词性还原
  2. 图像处理分类、一般流程与算法
  3. Batch Normalization应该放在ReLU非线性激活层的前面还是后面?
  4. 散列表查找(哈希表)
  5. 06 回归算法 - 损失函数、过拟合欠拟合
  6. CPU对指令长度的判断
  7. 各种图论模型及其解答(转)
  8. 求助大神!怎样除去XML节点反复的值的数据
  9. 转:Python 代码调试技巧
  10. EXCEL保存提示“隐私问题警告:此文档中包含宏……”解决办法