成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

解除openstack中instance對IP的限制

云計算 OpenStack
最近公司的幾個關鍵業務跑在openstack中的虛擬機中,想把幾個虛擬機做成負載均衡和高可用集群。

最近公司的幾個關鍵業務跑在openstack中的虛擬機中,想把幾個虛擬機做成負載均衡和高可用集群。

對于負載均衡,G版本已經集成了haproxy插件,對haproxy的配置做了一層封裝,可以很方便的通過quantum去創建一個負載均衡池,為相同或者不同宿主機上的虛擬機提供負載均衡的能力。

在這個模式下,haproxy是運行在宿主機上的。

遺憾的是,目前還不能通過openstack做到haproxy的高可用。

想要做高可用,只能在虛擬機中去飄VIP了

但是創建了虛擬機之后,在這個虛擬機實例中只能使用指定的IP。

這就導致想在虛擬機中部署高可用去飄VIP是不可行的。

可以理解,在公有云環境下,是不可能讓用戶在虛擬機中隨意去配置額外地址的。

但我們是私有云環境,這個規則對私有云環境下很是麻煩。

在openstack中創建虛擬機,通過nova boot的--nic選項指定網卡和IP地址:

--nic net-id=${NETWORK_ID},v4-fixed-ip=${Host_IP}

 

之前一直以為是iptables規則導致的。于是去看了一遍宿主機中的iptables規則

root@node1:~# iptables -vnL

Chain INPUT (policy ACCEPT 3556K packets, 744M bytes)

pkts bytes target prot opt in out source destination

1778K 372M nova-compute-INPUT all -- * * 0.0.0.0/0 0.0.0.0/0

 

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)

pkts bytes target prot opt in out source destination

150 13488 nova-filter-top all -- * * 0.0.0.0/0 0.0.0.0/0

6 1392 nova-compute-FORWARD all -- * * 0.0.0.0/0 0.0.0.0/0

 

Chain OUTPUT (policy ACCEPT 4208K packets, 567M bytes)

pkts bytes target prot opt in out source destination

4202K 567M nova-filter-top all -- * * 0.0.0.0/0 0.0.0.0/0

2106K 284M nova-compute-OUTPUT all -- * * 0.0.0.0/0 0.0.0.0/0

 

Chain nova-compute-FORWARD (1 references)

pkts bytes target prot opt in out source destination

4 1312 ACCEPT udp -- * * 0.0.0.0 255.255.255.255 udp spt:68 dpt:67

2 80 ACCEPT all -- brq3eefcd79-07 * 0.0.0.0/0 0.0.0.0/0

0 0 ACCEPT all -- * brq3eefcd79-07 0.0.0.0/0 0.0.0.0/0

 

Chain nova-compute-INPUT (1 references)

pkts bytes target prot opt in out source destination

2 656 ACCEPT udp -- * * 0.0.0.0 255.255.255.255 udp spt:68 dpt:67

 

Chain nova-compute-OUTPUT (1 references)

pkts bytes target prot opt in out source destination

 

Chain nova-compute-inst-15 (1 references)

pkts bytes target prot opt in out source destination

0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID

0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

0 0 nova-compute-provider all -- * * 0.0.0.0/0 0.0.0.0/0

0 0 ACCEPT udp -- * * 10.16.0.102 0.0.0.0/0 udp spt:67 dpt:68

0 0 ACCEPT all -- * * 10.16.0.0/24 0.0.0.0/0

0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 1:65535

0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 1:65535

0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0

0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 8 code 8

0 0 nova-compute-sg-fallback all -- * * 0.0.0.0/0 0.0.0.0/0

 

Chain nova-compute-inst-17 (1 references)

pkts bytes target prot opt in out source destination

0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID

0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

0 0 nova-compute-provider all -- * * 0.0.0.0/0 0.0.0.0/0

0 0 ACCEPT udp -- * * 10.16.0.102 0.0.0.0/0 udp spt:67 dpt:68

0 0 ACCEPT all -- * * 10.16.0.0/24 0.0.0.0/0

0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 1:65535

0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 1:65535

0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0

0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 8 code 8

0 0 nova-compute-sg-fallback all -- * * 0.0.0.0/0 0.0.0.0/0

 

Chain nova-compute-local (1 references)

pkts bytes target prot opt in out source destination

0 0 nova-compute-inst-15 all -- * * 0.0.0.0/0 10.16.0.111

0 0 nova-compute-inst-17 all -- * * 0.0.0.0/0 10.16.0.131

 

Chain nova-compute-provider (2 references)

pkts bytes target prot opt in out source destination

 

Chain nova-compute-sg-fallback (2 references)

pkts bytes target prot opt in out source destination

0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0

 

Chain nova-filter-top (2 references)

pkts bytes target prot opt in out source destination

2106K 284M nova-compute-local all -- * * 0.0.0.0/0 0.0.0.0/0


 

分析一下這些openstack自動生成的規則,可以看到input,forword和output鏈默認都是accept狀態。分析每條鏈對數據包的跳轉和過濾,如果在虛擬機中配置新的地址,是不會被過濾的。

 

經過一番折騰,最終發現限制IP的原因是ebtables在起作用

root@node1:~# ebtables -t nat -L

Bridge table: nat

 

Bridge chain: PREROUTING, entries: 2, policy: ACCEPT

-i tap0678bf1d-41 -j libvirt-I-tap0678bf1d-41

-i tap496fa038-9e -j libvirt-I-tap496fa038-9e

 

Bridge chain: OUTPUT, entries: 0, policy: ACCEPT

 

Bridge chain: POSTROUTING, entries: 0, policy: ACCEPT

 

Bridge chain: libvirt-I-tap0678bf1d-41, entries: 4, policy: ACCEPT

-j I-tap0678bf1d-41-mac

-p IPv4 -j I-tap0678bf1d-41-ipv4-ip

-p ARP -j I-tap0678bf1d-41-arp-mac

-p ARP -j I-tap0678bf1d-41-arp-ip

 

Bridge chain: I-tap0678bf1d-41-mac, entries: 2, policy: ACCEPT

-s fa:16:3e:a6:5f:70 -j RETURN

-j DROP

 

Bridge chain: I-tap0678bf1d-41-ipv4-ip, entries: 3, policy: ACCEPT

-p IPv4 --ip-src 0.0.0.0 --ip-proto udp -j RETURN

-p IPv4 --ip-src 10.16.0.131 -j RETURN

-j DROP

 

Bridge chain: I-tap0678bf1d-41-arp-mac, entries: 2, policy: ACCEPT

-p ARP --arp-mac-src fa:16:3e:a6:5f:70 -j RETURN

-j DROP

 

Bridge chain: I-tap0678bf1d-41-arp-ip, entries: 2, policy: ACCEPT

-p ARP --arp-ip-src 10.16.0.131 -j RETURN

-j DROP

 

Bridge chain: libvirt-I-tap496fa038-9e, entries: 4, policy: ACCEPT

-j I-tap496fa038-9e-mac

-p IPv4 -j I-tap496fa038-9e-ipv4-ip

-p ARP -j I-tap496fa038-9e-arp-mac

-p ARP -j I-tap496fa038-9e-arp-ip

 

Bridge chain: I-tap496fa038-9e-mac, entries: 2, policy: ACCEPT

-s fa:16:3e:58:1:ac -j RETURN

-j DROP

 

Bridge chain: I-tap496fa038-9e-ipv4-ip, entries: 3, policy: ACCEPT

-p IPv4 --ip-src 0.0.0.0 --ip-proto udp -j RETURN

-p IPv4 --ip-src 10.16.0.111 -j RETURN

-j DROP

 

Bridge chain: I-tap496fa038-9e-arp-mac, entries: 2, policy: ACCEPT

-p ARP --arp-mac-src fa:16:3e:58:1:ac -j RETURN

-j DROP

 

Bridge chain: I-tap496fa038-9e-arp-ip, entries: 2, policy: ACCEPT

-p ARP --arp-ip-src 10.16.0.111 -j RETURN

-j DROP

ebtables是linux專門做二層數據鏈路層過濾的。

 

在通過nova創建虛擬機后,會生成libvirt的一個xml配置文件

路徑在:/etc/libvirt/nwfilter/nova-base.xml

里面定義了以下規則,這些規則限制了在虛擬機上的地址,在二層上就做了過濾

<filter name='nova-base' chain='root'>

<uuid>12ec8693-253a-7db0-7cd3-f8cc0a1e1b02</uuid>

<filterref filter='no-mac-spoofing'/>

<filterref filter='no-ip-spoofing'/>

<filterref filter='no-arp-spoofing'/>

<filterref filter='allow-dhcp-server'/>

</filter>

 

然后為每個虛擬機創建一個xml文件,每個虛擬機的xml配置中包含了nova-base.xml中的配置

打開其中一個虛擬機的xml配置,可以看到,這個配置文件中只放行了指定IP在二層上可以通過,所以其它手動配置的地址是不可用的。

cat /etc/libvirt/nwfilter/nova-instance-instance-0000000f-fa163e5801ac.xml

<filter name='nova-instance-instance-0000000f-fa163e5801ac' chain='root'>

<uuid>972d18be-2db0-4bf2-2853-a0a61beac036</uuid>

<filterref filter='nova-base'>

<parameter name='DHCPSERVER' value='10.16.0.102'/>

<parameter name='IP' value='10.16.0.111'/>

<parameter name='PROJMASK' value='255.255.255.0'/>

<parameter name='PROJNET' value='10.16.0.0'/>

</filterref>

</filter>

 

libvirt可以通過在這些xml配置的規則,去生成ebtables規則,最終是ebtables做出限制。

 

如何破解?

修改nova-base.xml文件

注釋掉以下三行

<filterref filter='no-mac-spoofing'/>

<filterref filter='no-ip-spoofing'/>

<filterref filter='no-arp-spoofing'/>

然后重啟libvirt進程,libvirt會重新讀取xml中的配置,生成新的ebtables規則。

修改后,我通過新建虛擬機,重啟nova-computer進程,或者直接重啟宿主機,這個base文件都不會發生變化了。

 

還有就是修改nova源碼(未測試)

源碼位置在

/usr/lib/python2.7/dist-packages/nova/virt/libvirt/firewall.py

第198行(G版本中)

151457483.jpg

去掉no-mac-spoofing,no-ip-spoofing,no-arp-spoofing這三行,以后生成nova-base.xml文件就可以不包含這3個選項了。

 

本文出自 “lustlost-迷失在欲望之中” 博客,請務必保留此出處http://lustlost.blog.51cto.com/2600869/1324832

責任編輯:王程程 來源: 51CTO博客
相關推薦

2010-06-09 14:55:11

TCP IP協議限制

2013-06-09 09:26:07

路由器設置路由器

2011-08-03 15:40:09

注冊表注冊表編輯器

2021-06-30 13:13:55

IP地址網絡IP限制

2009-08-15 10:40:00

2011-04-18 15:33:33

Ubuntu 11.0

2019-06-04 10:24:11

2009-07-21 16:23:57

2025-02-28 05:50:12

2009-12-07 14:28:14

2009-01-12 08:04:27

Windows 7DVD鏡像數量限制

2015-08-17 11:01:49

OpenStack開源云架構應用遷移

2014-04-24 10:06:01

OpenStackDocker

2021-03-04 11:49:19

MySQL賬號IP

2019-06-03 10:08:57

華為禁令開發

2013-12-03 09:31:33

VMwareOpenStack云基礎架構

2015-06-15 09:43:05

SDNOpenStack N

2013-11-29 14:24:05

VMware

2015-06-09 09:51:20

SDNOpenStackNeutron

2015-09-01 10:05:17

OpenStackDocker
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 久久久www成人免费无遮挡大片 | 91麻豆精品国产91久久久更新资源速度超快 | 日韩午夜场 | 蜜桃传媒一区二区 | 中文字幕在线精品 | 成人在线视频一区二区三区 | 精品国产乱码久久久久久丨区2区 | h片在线观看免费 | 91xxx在线观看 | 毛片网站免费观看 | 亚洲一区二区三区高清 | 国产高清一区二区三区 | 久久久青草婷婷精品综合日韩 | 国产亚洲成av人片在线观看桃 | 国产精品一区二区三区99 | 久久精品日产第一区二区三区 | 国产精品有限公司 | 亚洲视频www | 99久久免费精品国产免费高清 | 日韩国产中文字幕 | 久久九| 日韩欧美1区2区 | 国产成人在线播放 | 91高清视频在线观看 | 在线观看中文视频 | 综合九九| 亚洲区一区二区 | 日韩中文字幕一区二区 | 日韩色综合 | 国产日韩视频 | 极品销魂美女一区二区 | 视频一区在线 | 91天堂| 欧美综合国产精品久久丁香 | 91久久精品一区二区二区 | 亚洲美女在线一区 | 精品1区2区 | 91久久精品一区二区三区 | 精品国产免费人成在线观看 | 蜜桃av鲁一鲁一鲁一鲁 | 国产精品久久精品 |