自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

解除openstack中instance對IP的限制

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

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

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

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

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

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

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

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

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

但我們是私有云環(huán)境,這個規(guī)則對私有云環(huán)境下很是麻煩。

在openstack中創(chuàng)建虛擬機,通過nova boot的--nic選項指定網(wǎng)卡和IP地址:

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

 

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

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自動生成的規(guī)則,可以看到input,forword和output鏈默認都是accept狀態(tài)。分析每條鏈對數(shù)據(jù)包的跳轉(zhuǎn)和過濾,如果在虛擬機中配置新的地址,是不會被過濾的。

 

經(jīng)過一番折騰,最終發(fā)現(xiàn)限制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專門做二層數(shù)據(jù)鏈路層過濾的。

 

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

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

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

<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>

 

然后為每個虛擬機創(chuàng)建一個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配置的規(guī)則,去生成ebtables規(guī)則,最終是ebtables做出限制。

 

如何破解?

修改nova-base.xml文件

注釋掉以下三行

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

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

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

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

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

 

還有就是修改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博客
相關(guān)推薦

2010-06-09 14:55:11

TCP IP協(xié)議限制

2013-06-09 09:26:07

路由器設置路由器

2011-08-03 15:40:09

注冊表注冊表編輯器

2021-06-30 13:13:55

IP地址網(wǎng)絡IP限制

2009-08-15 10:40:00

2011-04-18 15:33:33

Ubuntu 11.0

2009-07-21 16:23:57

2019-06-04 10:24:11

2025-02-28 05:50:12

2009-12-07 14:28:14

2009-01-12 08:04:27

Windows 7DVD鏡像數(shù)量限制

2015-08-17 11:01:49

OpenStack開源云架構(gòu)應用遷移

2014-04-24 10:06:01

OpenStackDocker

2021-03-04 11:49:19

MySQL賬號IP

2019-06-03 10:08:57

華為禁令開發(fā)

2013-11-29 14:24:05

VMware

2013-12-03 09:31:33

VMwareOpenStack云基礎架構(gòu)

2015-06-15 09:43:05

SDNOpenStack N

2015-06-09 09:51:20

SDNOpenStackNeutron

2015-09-01 10:05:17

OpenStackDocker
點贊
收藏

51CTO技術(shù)棧公眾號