文章目录
- openstack虚拟机IP通网关但同网段IP不互通处理方法
-
- Openstack中单网卡使用多ip
openstack虚拟机IP通网关但同网段IP不互通处理方法
问题描述
- 云平台的防火墙虚拟机部署再我们云平台上,防火墙虚拟机所属物理机坏了,将虚拟机迁移到别的宿主机上后,出现了以下问题
- 1、虚拟机能通网关,但同网段直接不能互通【并非全部,偶尔有一两台能互通】;
- 2、有外网的主机,部分能正常使用。
处理方法
[root@computer04 ~]
-A neutron-linuxbri-s679500a7-9 -s 192.168.244.125/32 -m mac --mac-source FA:16:3E:95:08:2C -m comment --comment "Allow traffic from defined IP/MAC pairs." -j RETURN
[root@computer04 ~]
-N neutron-linuxbri-s679500a7-9
-A neutron-linuxbri-o679500a7-9 -j neutron-linuxbri-s679500a7-9
-A neutron-linuxbri-s679500a7-9 -s 192.168.244.125/32 -m mac --mac-source FA:16:3E:95:08:2C -m comment --comment "Allow traffic from defined IP/MAC pairs." -j RETURN
-A neutron-linuxbri-s679500a7-9 -m comment --comment "Drop traffic without an IP/MAC allow rule." -j DROP
[root@computer04 ~]
[root@computer04 ~]
[root@computer04 ~]
[root@computer04 ~]
-N neutron-linuxbri-s679500a7-9
-A neutron-linuxbri-o679500a7-9 -j neutron-linuxbri-s679500a7-9
-A neutron-linuxbri-s679500a7-9 -s 192.168.244.125/32 -m mac --mac-source FA:16:3E:95:08:2C -m comment --comment "Allow traffic from defined IP/MAC pairs." -j RETURN
-A neutron-linuxbri-s679500a7-9 -j ACCEPT
[root@computer04 ~]
- 放个图片,记录一下,现在公有云防火墙虚拟机在
computer04
上,如果后面换主机了,这些操作全部得再新宿主机上执行一遍。。。不然网络还是有问题。
Openstack中单网卡使用多ip
-
其实我上面的操作实现的效果也是单网卡使用多IP。下面内容来源于网络,更主要是介绍单网卡使用多IP这个概念
-
创建虚拟机时主机上会有一条iptables 用来将ip和mac绑定,用来防止arp欺骗。在需要给单个网卡配置多个ip的场景下(例如keepalive)另外添加的ip地址是无法与外界通信的。 两种方法来解决。
-
第一种是使用allowed-address-pairs来扩展端口属性,允许手动指定端口的mac_address和ip 地址对的流量通过。
-
- 建立port时指定allowed-address-pairs属性
# neutron port-create e13762dc-9af7-49b6-a74e-2ed2a9728a6c --allowed-address-pairs type=dict list=true ip_address=172.16.1.5
可以看出新建的port的ip_address为172.16.1.7,而对应的allowed-address-pairs为172.16.1.5,两个ip对应的mac是相同的。
-
- 给现有网卡添加allowed-address-pairs属性
# neutron port-update 18dea4cb-db1d-4c44-96f0-0b57305e7b1e --allowed-address-pairs type=dict list=true ip_address=172.16.1.23
-
设置了属性后主机的iptables如下:
RETURN all -- 172.16.1.5 anywhere MAC FA:16:3E:65:5B:C7 /* Allow traffic from defined IP/MAC pairs. */
RETURN all -- 172.16.1.4 anywhere MAC FA:16:3E:65:5B:C7 /* Allow traffic from defined IP/MAC pairs. */
-
第二种是使用port_security_enabled
属性,可以针对整个网络更改,也针对某个端口更改。
创建net和port时现在没有参数来指定port_security_enabled
,默认是True,所以需要在创建之后更新。
-
首先移除port上的安全组(创建port时默认是有安全组的,可以添加参数–no-security-groups创建没有安全组的prot),然后设置port的port_security_enabled为False(有安全组时port_security_enabled无法设置为False ) :
neutron port-update b0ddb9ad-6250-45f2-9927-a6633ddaf406 --no-security-groups --port_security_enabled=False
- 设置了port_security_enabled=False后再主机的iptables中对应的下面规则会被删除。
RETURN all -- 172.16.1.4 anywhere MAC FA:16:3E:65:5B:C7 /* Allow traffic from defined IP/MAC pairs. */
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)