创建浮动IP步骤

创建浮动IP步骤:
1、之前已经创建了外部的provider网络:out了,直接在这个网络上创建子网:out_subnet。浮动IP就在这个子网上分配
2、在浮动IP里面选择分配IP给项目,选择out网络,则自动从里面分配一个IP作为浮动IP
3、这时想在实例里面绑定浮动IP,会发现无可用接口。这是因为浮动IP是要跟路由配合使用的,我们之前创建了外部网络out(flat类型),又创建了内部网络net4。新建立的虚拟机就是从net4的子网分配IP的。但两个网络是没有联系的。而连接这两个网络的就是路由,实际上是一个namespace。我们在网络----路由里面创建一个路由,并指定外部网络为out,再在路由里面连接接口指定网络为net4,这样就把内外两个网络连接起来了。这时实例里面绑定浮动IP就会发现可选择内部接口中了。

docker exec openvswitch_vswitchd ovs-vsctl show
ea384205-37b0-413f-bd44-06db00aee861
    Manager "ptcp:6640:127.0.0.1"
        is_connected: true
    Bridge br-int
        Controller "tcp:127.0.0.1:6633"
            is_connected: true
        fail_mode: secure
        datapath_type: system
        Port patch-tun
            Interface patch-tun
                type: patch
                options: {peer=patch-int}
        Port "qg-eb97210d-52"
            tag: 5
            Interface "qg-eb97210d-52"
                type: internal
        Port "tapfbbaca45-5e"
            tag: 3
            Interface "tapfbbaca45-5e"
                type: internal
        Port "qr-470ed630-a5"
            tag: 2
            Interface "qr-470ed630-a5"
                type: internal
        Port br-int
            Interface br-int
                type: internal
        Port "qg-fe577841-3e"
            tag: 5
            Interface "qg-fe577841-3e"
                type: internal
        Port int-br-ex
            Interface int-br-ex
                type: patch
                options: {peer=phy-br-ex}
        Port "tap4e4dc7a9-7a"
            tag: 4
            Interface "tap4e4dc7a9-7a"
                type: internal
        Port "qr-1e86b87e-5c"
            tag: 3
            Interface "qr-1e86b87e-5c"
                type: internal
        Port "tap0d659160-84"
            tag: 1
            Interface "tap0d659160-84"
                type: internal
        Port "tap0e9fc4ce-c9"
            tag: 2
            Interface "tap0e9fc4ce-c9"
                type: internal
    Bridge br-tun
        Controller "tcp:127.0.0.1:6633"
            is_connected: true
        fail_mode: secure
        datapath_type: system
        Port br-tun
            Interface br-tun
                type: internal
        Port patch-int
            Interface patch-int
                type: patch
                options: {peer=patch-tun}
        Port "vxlan-0a678193"
            Interface "vxlan-0a678193"
                type: vxlan
                options: {df_default="true", egress_pkt_mark="0", in_key=flow, local_ip="10.103.129.149", out_key=flow, remote_ip="10.103.129.147"}
        Port "vxlan-0a678194"
            Interface "vxlan-0a678194"
                type: vxlan
                options: {df_default="true", egress_pkt_mark="0", in_key=flow, local_ip="10.103.129.149", out_key=flow, remote_ip="10.103.129.148"}
    Bridge br-ex
        Controller "tcp:127.0.0.1:6633"
            is_connected: true
        fail_mode: secure
        datapath_type: system
        Port phy-br-ex
            Interface phy-br-ex
                type: patch
                options: {peer=int-br-ex}
        Port "ens33"
            Interface "ens33"
        Port br-ex
            Interface br-ex
                type: internal

ip netns 查看命名空间
qdhcp-8d55e0d3-f6c1-49f4-834b-74565d57ded1 (id: 4)
qdhcp-4622d8cd-b2f5-4050-89b7-d9051e16c99e (id: 2)
qdhcp-232b0fe3-3c92-4a72-b484-9296e365a594 (id: 5)
qdhcp-ae661cfd-f6df-4c70-90d3-58265c37f62e (id: 3)
qrouter-feefd039-90b0-4a57-bbe0-716d5507e623 (id: 0)
qrouter-11d8393e-cfb1-46be-89ff-b14c61d4a410 (id: 1)
可以看到qrouter-11d8393e-cfb1-46be-89ff-b14c61d4a410 是我新建立的路由
ip netns exec qrouter-11d8393e-cfb1-46be-89ff-b14c61d4a410 ip add
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
19: qr-470ed630-a5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether fa:16:3e:31:41:da brd ff:ff:ff:ff:ff:ff
    inet 172.16.1.1/24 brd 172.16.1.255 scope global qr-470ed630-a5
       valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fe31:41da/64 scope link
       valid_lft forever preferred_lft forever
21: qg-eb97210d-52: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether fa:16:3e:11:c1:fd brd ff:ff:ff:ff:ff:ff
    inet 10.100.0.141/24 brd 10.100.0.255 scope global qg-eb97210d-52
       valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fe11:c1fd/64 scope link
       valid_lft forever preferred_lft forever

qr-470ed630-a5 这个接口就是路由器接口,跟内部网络相联。qg-eb97210d-52是连接out网络。qr-470ed630-a5和tap0e9fc4ce-c9都属于tag 2。tap0e9fc4ce-c9是虚拟机的网络接口。
qg-eb97210d-52这个属于tag 5归属于out网络的子网,这个是跟ens33桥接的,可以从这个出外网。
VM虚拟机tap0e9fc4ce-c9(tag 2)--------qr-470ed630-a5(tag 2)----qrouter-11d8393e-cfb1-46be-89ff-b14c61d4a410--SNAT--qg-eb97210d-52(tag 5)-------br-ex----ens33----外网

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值