找回密码
 注册
查看: 5215|回复: 1

neutron ipsecvpn create step

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2019-4-26 10:09:31 | 显示全部楼层 |阅读模式

$ H. N. U( B! d* u5 x' n8 {2 i/ p- j$ \4 J. p0 ]8 x! T. M- z. I
以下为手动编写这个文件:: E( R( k1 b. }. P
cd /usr/share/openstack-dashboard/openstack_dashboard/enabled/+ ]* Z+ F8 o- v6 u
touch _7100_project_vpn_panel.py' B$ p9 E6 \. y. K7 e. G
文件内容如下:
4 x, T. N5 B) g: L- T" q% X: j[root@localhost enabled]# vim _7100_project_vpn_panel.py
7 S- _/ y, G* v, {6 n4 x# Licensed under the Apache License, Version 2.0 (the "License"); you may  x; g, g+ E" k7 H1 j% c
# not use this file except in compliance with the License. You may obtain' D' I( T( p1 D8 U
# a copy of the License at( o& B& s; S" |/ S7 x
#
3 ?3 f; Q* B/ V7 `3 d9 G# http://www.apache.org/licenses/LICENSE-2.0; h: y# H' f" Z
#6 J- O$ r  y2 A, D
# Unless required by applicable law or agreed to in writing, software
) F; V* H7 f9 J0 D: n3 r6 l) H# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT, |/ h1 A1 L5 I' g% G
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
3 S. V4 k$ h1 {4 f6 B" [$ p9 Y# License for the specific language governing permissions and limitations" z9 \1 d- P) ?  [; L" ~
# under the License.
  F" ?% ]$ f8 R/ {( }' K% a( e4 g1 A3 e
# The slug of the panel to be added to HORIZON_CONFIG. Required.
- ?( F- ]- V; K% `% JPANEL = 'vpn'- D$ J6 S: O  p# X+ ^1 c# s( }
# The slug of the dashboard the PANEL associated with. Required.
1 D4 {6 Q+ e& d1 C: lPANEL_DASHBOARD = 'project'
% H! B, J# M5 q7 h7 F3 s# The slug of the panel group the PANEL is associated with.
% A6 X( m+ S# B: YPANEL_GROUP = 'network'
" t0 M; P0 l$ Q
3 }' V4 W" V+ s6 G1 X# Python panel class of the PANEL to be added.
$ U3 {/ F. _* f% _ADD_PANEL = 'neutron_vpnaas_dashboard.dashboards.project.vpn.panel.VPN'
$ m' Q4 k: W9 U
( q% D- v& E# ]7 N8 }( FADD_INSTALLED_APPS = ["neutron_vpnaas_dashboard"]
6 ?9 G" W5 n2 o. Q- G5 w, }4 |% R- k; t  C7 Z; Q, @" p

" d# E$ k' Y6 o* l7 K  Y4.1 vim /etc/neutron/neutron.conf3 K. o. m; r" g& A) E$ [5 b
[DEFAULT]
6 m3 e- [3 ^5 ~# \service_plugins = router,vpnaas7 X& j0 ]' N- n3 F

4 V, P" o) @; l1 P4.2 vim  /etc/neutron/neutron_vpnaas.conf
+ F; [$ A8 S' N: `$ K[service_providers]
9 i* E9 Y1 u& d' g4 vservice_provider = VPN:strongswan:neutron_vpnaas.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default, t! T/ e1 L5 C! w9 z
4 m7 A. ~+ S/ g7 \9 h
4.3 vim /etc/neutron/l3_agent.ini' N5 ]( X% _2 g$ Y2 H# Q
[agent]
1 Q6 K6 T7 `/ Iextensions = vpnaas. Q2 j( Q. x0 W8 R6 I$ ]( H; z3 C( w
[vpnagent]
) D  _3 |* B& r3 Lvpn_device_driver = neutron_vpnaas.services.vpn.device_drivers.strongswan_ipsec.StrongSwanDriver5 w% i" _: n- O
% q3 D0 J. Y3 o: ]: C7 `+ s- A
4.4 执行 neutron-db-manage --subproject neutron-vpnaas upgrade head
1 N! R/ X) M9 _4 w9 [$ w7 _" u/ B+ t! N" l& p3 I- J; \* W) U
5. 重启服务+ q  d% N& x+ B/ P* @$ Z
systemctl restart neutron-server
' x0 r+ `% `6 |systemctl restart neutron-l3-agent
. h6 N7 l) e9 Y7 w% T* Hsystemctl restart apache2% D  B8 \' j& _* t' q0 E) l( g7 G
---------------------
6 `9 x4 G4 j! _9 L+ V$ E* u& s0 X. @4 l
( \! F4 @1 D0 O( ]8 f5 v
7 N. J7 \  ?" m' M
Virtual Private Network-as-a-Service (VPNaaS) ( `6 m- l8 ~. b8 z9 _3 Z" H; b9 D
  5 [8 s0 e* `7 o8 }! P; F4 a; b
THIS PAGE LAST UPDATED: $ H0 r7 U3 _7 G8 j
Enabling VPNaaS¶
' Q' M. b' w. @$ eThis section describes the setting for the reference implementation. Vendor plugins or drivers can have different setup procedure and perhaps they provide their version of manuals.
- }& q( v5 s1 r; Z. uEnable the VPNaaS plug-in in the /etc/neutron/neutron.conf file by appending vpnaas to service_plugins in [DEFAULT]:
9 l4 o4 z. W4 u[DEFAULT]& Y) G0 }; m; n0 g
# ...
: [) |* r+ e/ `$ `/ D  I1 Kservice_plugins = vpnaas
/ l' s" I% j" G" G2 O$ J Note5 T: m# q% L0 Z, L
vpnaas is just example of reference implementation. It depends on a plugin that you are going to use. Consider to set suitable plugin for your own deployment.
$ H/ H. m1 z5 h0 ^Configure the VPNaaS service provider by creating the /etc/neutron/neutron_vpnaas.conf file as follows, strongswan used in Ubuntu distribution:
8 G& q) p0 d5 k1 Z; w* c0 U5 W* |- W[service_providers]
& c  d, E4 R/ \% c0 o- y6 }service_provider = VPN:strongswan:neutron_vpnaas.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default6 F, L$ P" F3 G% b
Note
( \8 n8 q$ H" n1 b1 _$ cThere are several kinds of service drivers. Depending upon the Linux distribution, you may need to override this value. Select libreswan for RHEL/CentOS, the config will like this: service_provider = VPN:openswan:neutron_vpnaas.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default. Consider to use the appropriate one for your deployment.
, \( S* `0 Y# z% QConfigure the VPNaaS plugin for the L3 agent by adding to /etc/neutron/l3_agent.ini the following section, StrongSwanDriver used in Ubuntu distribution:$ A, K, w- H. j+ @8 {
[AGENT]5 A  O! \& a% V) a) X; v6 }
extensions = vpnaas8 W2 R2 U# R  [- Z9 e& N9 b/ T
[vpnagent]* R# ~1 I+ P; l* j3 s; ^5 L! V
vpn_device_driver = neutron_vpnaas.services.vpn.device_drivers.strongswan_ipsec.StrongSwanDriver
$ V, I% l: Z: V' l, b2 ^0 b- x6 V Note6 k* @: t. w& c$ G) z
There are several kinds of device drivers. Depending upon the Linux distribution, you may need to override this value. Select LibreSwanDriver for RHEL/CentOS, the config will like this: vpn_device_driver = neutron_vpnaas.services.vpn.device_drivers.libreswan_ipsec.LibreSwanDriver. Consider to use the appropriate drivers for your deployment.
4 A5 f& l4 ?0 I7 z/ v" i9 cCreate the required tables in the database:; o2 B! O7 B9 C+ [" G3 w
# neutron-db-manage --subproject neutron-vpnaas upgrade head4 a" g* ^0 r6 n+ S
Note- y7 U, l' d# x0 u4 h
In order to run the above command, you need to have neutron-vpnaas package installed on controller node.
9 z2 X6 s4 g9 r% `% RRestart the neutron-server in controller node to apply the settings.
/ d- C5 e  Z5 s9 a) @9 T; eRestart the neutron-l3-agent in network node to apply the settings.
6 h# c% ]& T1 e/ ?Using VPNaaS with endpoint group (recommended)¶& j8 L5 ~2 [; A
IPsec site-to-site connections will support multiple local subnets, in addition to the current multiple peer CIDRs. The multiple local subnet feature is triggered by not specifying a local subnet, when creating a VPN service. Backwards compatibility is maintained with single local subnets, by providing the subnet in the VPN service creation.
5 M  u6 Z% v6 q& n0 ?To support multiple local subnets, a new capability called “End Point Groups” has been added. Each endpoint group will define one or more endpoints of a specific type, and can be used to specify both local and peer endpoints for IPsec connections. The endpoint groups separate the “what gets connected” from the “how to connect” for a VPN service, and can be used for different flavors of VPN, in the future.
/ c  J! B" R0 a4 c8 }- F6 @Refer Multiple Local Subnets for more detail.
; E/ R: E( s% o$ g9 dCreate the IKE policy, IPsec policy, VPN service, local endpoint group and peer endpoint group. Then, create an IPsec site connection that applies the above policies and service.$ W  V3 c( V: w& {
Create an IKE policy:) H+ @9 [3 e' t
$ openstack vpn ike policy create ikepolicy
+ \/ }) S: I, y, o  +-------------------------------+----------------------------------------+
& i' R. W$ l5 N' V( u9 {1 g  | Field                         | Value                                  |
) \4 v( O9 [3 V; _" c  +-------------------------------+----------------------------------------+
# j4 B% Y+ E$ I$ _7 O: a' F  | Authentication Algorithm      | sha1                                   |
! m8 a- ?2 O, {5 R+ M2 }- T  | Description                   |                                        |
0 j. i' Y0 P  N. A  | Encryption Algorithm          | aes-128                                |" E; x/ e! w& N2 ]! X& [, X( e! J
  | ID                            | 735f4691-3670-43b2-b389-f4d81a60ed56   |+ k# N( z4 I3 O6 L7 |2 b
  | IKE Version                   | v1                                     |
5 f; y1 \4 |, c' t# R" h  | Lifetime                      | {u'units': u'seconds', u'value': 3600} |
5 d; J9 q5 p  Z8 P  w" |1 L  | Name                          | ikepolicy                              |
( D8 j& K+ @) b4 M  | Perfect Forward Secrecy (PFS) | group5                                 |& A, j" t! W4 z2 @+ i: i" ]
  | Phase1 Negotiation Mode       | main                                   |) K: W0 s. {# k
  | Project                       | 095247cb2e22455b9850c6efff407584       |/ V. O% J# Z# J9 N  i5 r. [- C3 e
  | project_id                    | 095247cb2e22455b9850c6efff407584       |
3 ^1 {! P& k" b& d  +-------------------------------+----------------------------------------+
. d! R$ u! C; `0 u1 s) g5 X/ g' a  }" X6 KCreate an IPsec policy:
" ?7 ~$ }$ A- [, f  y% h; ]) r2 ]$ openstack vpn ipsec policy create ipsecpolicy8 o- {8 l) v+ I$ Y6 \
  +-------------------------------+----------------------------------------+5 U0 ?# b" m1 \7 u
  | Field                         | Value                                  |
, v7 g, ~9 C9 [" M  +-------------------------------+----------------------------------------+
# _7 Z# q- W8 S0 ]: `/ u7 d# g  | Authentication Algorithm      | sha1                                   |
# n* Z4 _( {5 u9 b  | Description                   |                                        |
2 b6 k9 ?/ C4 h. r  | Encapsulation Mode            | tunnel                                 |, M. ]: x: ?! {1 Y
  | Encryption Algorithm          | aes-128                                |" L9 F: H9 c% @: \, i
  | ID                            | 4f3f46fc-f2dc-4811-a642-9601ebae310f   |2 Y8 R* k% u# W+ _: }+ c2 u
  | Lifetime                      | {u'units': u'seconds', u'value': 3600} |
& m, o8 C8 N; l  | Name                          | ipsecpolicy                            |
: ^4 @' R" o& q  A5 A1 p1 Q  | Perfect Forward Secrecy (PFS) | group5                                 |$ \7 v, Y1 D6 C6 P, ]
  | Project                       | 095247cb2e22455b9850c6efff407584       |. N, K0 R! I" V5 L: e  }' P& o
  | Transform Protocol            | esp                                    |
" e' l5 r3 n: Y$ l7 m3 X1 ]0 t  | project_id                    | 095247cb2e22455b9850c6efff407584       |. a# [; X' E8 b: M
  +-------------------------------+----------------------------------------+
/ Z! N0 C/ a+ H* h2 |% b9 HCreate a VPN service:* e6 U0 t1 o" u2 }  K+ o% y" o4 V, [
$ openstack vpn service create vpn \
( O3 \# K, |# I  Z  }2 f! m* Y8 Z  --router 9ff3f20c-314f-4dac-9392-defdbbb36a66
- W% C3 ~5 M1 W! ]8 _6 q- i2 Q  +----------------+--------------------------------------+% v2 _! l, H2 ~0 O: W- f
  | Field          | Value                                |# e$ k7 k& o5 T! E" _
  +----------------+--------------------------------------+
* N% e1 G! l- R4 X  | Description    |                                      |; B" {5 `! y" i& y' ~. M3 n$ b7 ]$ |
  | Flavor         | None                                 |
# I9 p* X2 Z" ]7 T: |8 U  | ID             | 9f499f9f-f672-4ceb-be3c-d5ff3858c680 |
! _3 i  K8 ]7 V0 I. M  | Name           | vpn                                  |
, J# i$ h& n2 z  | Project        | 095247cb2e22455b9850c6efff407584     |" i- Y2 w6 F( F- b6 u4 Z; t
  | Router         | 9ff3f20c-314f-4dac-9392-defdbbb36a66 |8 D0 R& v; b- Y2 y" \/ ]) @
  | State          | True                                 |
6 M6 s1 }8 M4 c  | Status         | PENDING_CREATE                       |' `7 c. b; K$ r: \, w
  | Subnet         | None                                 |9 C5 X+ P% t0 \$ A2 o
  | external_v4_ip | 192.168.20.7                         |  c1 |4 N" W% X2 X5 A
  | external_v6_ip | 2001:db8::7                          |
+ H! U" D; k* z7 q; O8 W6 k4 X5 R  | project_id     | 095247cb2e22455b9850c6efff407584     |
+ o- x6 W  p% G( t* t  +----------------+--------------------------------------+
8 P7 r9 H' E- j1 ~  @9 o Note
; x" F# X/ H( X: BPlease do not specify --subnet option in this case.4 s* v% d+ {" t0 J- j' o! p
The Networking openstackclient requires a router (Name or ID) and name.
5 b  _5 x1 R+ \3 N2 L7 u# O5 BCreate local endpoint group:8 @0 c# ~& t1 {- S$ k
$ openstack vpn endpoint group create ep_subnet \
, H" x8 I: Y& I  @( j  --type subnet \
, O! d2 L/ g- Z* k2 H# B% O  --value 1f888dd0-2066-42a1-83d7-56518895e47d7 {; w% }; f" W+ T" o9 t& J
  +-------------+-------------------------------------------+& p6 ?6 G, x: R  U' N  K6 F; c6 O
  | Field       | Value                                     |3 P2 z" _, q: g
  +-------------+-------------------------------------------+5 h! `0 V" g% j/ r% Q' b! A
  | Description |                                           |
' G4 r- v8 d5 A  | Endpoints   | [u'1f888dd0-2066-42a1-83d7-56518895e47d'] |
, B" K7 y8 J) c& O  C  | ID          | 667296d0-67ca-4d0f-b676-7650cf96e7b1      |1 Y% `1 U8 z7 |1 c6 z! D
  | Name        | ep_subnet                                 |
7 e2 Z  y: A# G. ^, m5 V( l  | Project     | 095247cb2e22455b9850c6efff407584          |4 \' C2 ^3 f0 M- G) N+ a# B% N( Q, o
  | Type        | subnet                                    |1 v1 a  ?5 a% C* ]! h% W
  | project_id  | 095247cb2e22455b9850c6efff407584          |# K+ v5 v2 d% C/ ]; u" s0 R
  +-------------+-------------------------------------------+
5 ~0 Y  ]& e. D Note
' ]% |! r1 L* V' ~The type of a local endpoint group must be subnet.
/ ^% _$ }( G; T: B/ U! Q  ]- ^Create peer endpoint group:
8 s, r4 I) ~  t; ^% C$ openstack vpn endpoint group create ep_cidr \8 r" L3 D' C) Y7 h* L
  --type cidr \
. r/ U' t& J! o+ I1 j2 e/ ]# H( S  --value 192.168.1.0/243 \6 B3 M9 e/ K' z
  +-------------+--------------------------------------+6 b) w3 a% X# V! \0 @
  | Field       | Value                                |* F& A3 G& ?6 a, P7 K
  +-------------+--------------------------------------+
+ F# u- ^" [* Q" n6 X+ ]0 e+ l  | Description |                                      |
" t  `2 P# H8 s; ^3 {: ]  | Endpoints   | [u'192.168.1.0/24']                  |5 r4 \) J# y: ]- L( d4 _4 z
  | ID          | 5c3d7f2a-4a2a-446b-9fcf-9a2557cfc641 |
3 a- X+ E- ~) w( B/ l- A  | Name        | ep_cidr                              |
! X. j0 X* h. \: c/ K; p) l  | Project     | 095247cb2e22455b9850c6efff407584     |
% U" a1 Y0 J+ C% r4 Z9 g/ ^  | Type        | cidr                                 |9 c) H, Q& L0 ?; f5 P  s+ \. o4 K$ L
  | project_id  | 095247cb2e22455b9850c6efff407584     |. b! B2 p; r& y# |* r. N
  +-------------+--------------------------------------+
" S/ x  L4 t. |9 N Note% X8 }% Y8 K6 v3 s3 u
The type of a peer endpoint group must be cidr.! N2 t  i7 t( t: g& A
Create an ipsec site connection:1 d# g* j4 ?; z) p! J
$ openstack vpn ipsec site connection create conn \1 U6 P0 x* p. s0 A$ o, S$ S
  --vpnservice vpn \) o/ N% Z% a5 R9 U* C
  --ikepolicy ikepolicy \
0 P  D. I2 m- s0 Z  --ipsecpolicy ipsecpolicy \) |- H0 q+ h  S% d) B
  --peer-address 192.168.20.9 \$ \  S5 J: f/ B4 t" |7 B  P
  --peer-id 192.168.20.9 \" X0 H+ \7 }  W  [6 z+ \$ ?3 R' h
  --psk secret \; ^: s, Y; j7 v9 s# O! O
  --local-endpoint-group ep_subnet \
# M; I$ @3 {" E5 }4 h. K! ]  --peer-endpoint-group ep_cidr% R: o# ]! \1 H+ s. V
  +--------------------------+--------------------------------------------------------+
" C* c" V; f, C7 {0 Q) H2 `  | Field                    | Value                                                  |
+ N, b4 r/ g- g6 H: w1 A  +--------------------------+--------------------------------------------------------+" q% Z. t1 d! |, R1 F
  | Authentication Algorithm | psk                                                    |
. D+ P3 E# p+ u4 k- Z  | Description              |                                                        |; \) A2 }* U: L( g  y& h
  | ID                       | 07e400b7-9de3-4ea3-a9d0-90a185e5b00d                   |3 e2 |! g: D1 H( K" l7 t; ~. o8 P
  | IKE Policy               | 735f4691-3670-43b2-b389-f4d81a60ed56                   |
; g) d( N$ L( f  | IPSec Policy             | 4f3f46fc-f2dc-4811-a642-9601ebae310f                   |
! Q( l. g$ B7 Y8 \# `  | Initiator                | bi-directional                                         |
3 p) b* ]' V1 K$ X  | Local Endpoint Group ID  | 667296d0-67ca-4d0f-b676-7650cf96e7b1                   |
0 u) R. k+ d- h! v" C1 R/ {7 k& S  | Local ID                 |                                                        |
4 z. |+ D. M8 |0 q  | MTU                      | 1500                                                   |
; P0 n$ E2 D6 {8 a  | Name                     | conn                                                   |
# n- P; M/ a! N  | Peer Address             | 192.168.20.9                                           |# b, O7 V/ _. `# ~5 O) y8 ~! ]
  | Peer CIDRs               |                                                        |% m) ]$ i. e- U2 S8 x2 u
  | Peer Endpoint Group ID   | 5c3d7f2a-4a2a-446b-9fcf-9a2557cfc641                   |: i* q+ c/ [, b3 l
  | Peer ID                  | 192.168.20.9                                           |
# v+ `4 J0 a7 B# k. ]# w! Q  | Pre-shared Key           | secret                                                 |2 [1 t  J- w* g- N! L; }
  | Project                  | 095247cb2e22455b9850c6efff407584                       |- [) l8 e; G; P! o: i7 X
  | Route Mode               | static                                                 |9 i7 Z/ Y6 b1 Y
  | State                    | True                                                   |/ f; g& V: m% H" g5 }, q9 }
  | Status                   | PENDING_CREATE                                         |
- ~! \4 @/ `- u6 _$ N" a" C: E  | VPN Service              | 9f499f9f-f672-4ceb-be3c-d5ff3858c680                   |4 ^' N3 O9 D( H
  | dpd                      | {u'action': u'hold', u'interval': 30, u'timeout': 120} |
/ P/ i% w, t5 {. M* J% V  | project_id               | 095247cb2e22455b9850c6efff407584                       |
( {3 U6 [) f3 k6 n6 Q& u. E  +--------------------------+--------------------------------------------------------+
$ G# t6 e* P% ]6 b5 h( ]0 i, E Note
) }1 _" w* J5 K, ^- ?: ?1 x) CPlease do not specify --peer-cidr option in this case. Peer CIDR(s) are provided by a peer endpoint group.
% M$ ~# q8 ]$ v. E/ E, }0 `( iConfigure VPNaaS without endpoint group (the legacy way)¶
0 U; Q$ K" r9 k$ k- C/ R# }+ @Create the IKE policy, IPsec policy, VPN service. Then, create an ipsec site connection that applies the above policies and service.
8 f% s2 D( b% B. v$ @Create an IKE policy:: f* p* J, q7 {9 f9 x1 f
$ openstack vpn ike policy create ikepolicy1
1 J5 t3 ]5 |1 V3 [  +-------------------------------+----------------------------------------+; ^4 C' {9 m# C1 T- b
  | Field                         | Value                                  |0 |& X" g  j; E. o2 j! ~1 ?* z
  +-------------------------------+----------------------------------------+
# Y! s8 j* d  a. Q  | Authentication Algorithm      | sha1                                   |
' w3 `8 X4 e& ^& ^" M  | Description                   |                                        |7 [/ J+ i4 P4 s
  | Encryption Algorithm          | aes-128                                |
$ y4 X# n; f. d% u  n9 F2 a) o' c! X: s  | ID                            | 99e4345d-8674-4d73-acb4-0e2524425e34   |
7 b% b- e8 B) @- W5 K+ ~) L  | IKE Version                   | v1                                     |
8 h+ `* M) r, h/ c% |, n! Y. F  | Lifetime                      | {u'units': u'seconds', u'value': 3600} |3 U$ {4 g6 P% }! ^
  | Name                          | ikepolicy1                             |' \' |4 l; E5 q8 \/ V
  | Perfect Forward Secrecy (PFS) | group5                                 |
' Y' B# ?7 Y! ^/ V% W9 F3 M+ g  | Phase1 Negotiation Mode       | main                                   |
# x2 d& h* i! ?  i0 y7 x5 Y  | Project                       | 095247cb2e22455b9850c6efff407584       |5 F$ |, g- ^) `! \! I
  | project_id                    | 095247cb2e22455b9850c6efff407584       |
3 \& n$ q* N* e7 a( U% n! E( ~5 j' L  +-------------------------------+----------------------------------------+
1 Y# S1 g# B/ M( ~7 {! NCreate an IPsec policy:
+ ~5 t5 Y! O4 v" E2 Q: S$ openstack vpn ipsec policy create ipsecpolicy14 Z, y2 P3 o+ h% f) r! j
  +-------------------------------+----------------------------------------+1 t7 b: U8 L9 F& v/ i; Y# Z7 X
  | Field                         | Value                                  |
. D. Z4 L3 H4 Z& ?1 t/ y4 E) H  +-------------------------------+----------------------------------------+0 _# r9 h, t5 J& _$ z* T& k
  | Authentication Algorithm      | sha1                                   |8 k* h2 O+ H$ m$ Q- L) q( o% T0 f
  | Description                   |                                        |1 n  I& G8 G. L( r* O) o
  | Encapsulation Mode            | tunnel                                 |
( q  r$ r* O" p& @) u6 Q  | Encryption Algorithm          | aes-128                                |; f! ^1 l' B9 s
  | ID                            | e6f547af-4a1d-4c28-b40b-b97cce746459   |
/ r; g+ ^3 }8 ^9 ^  | Lifetime                      | {u'units': u'seconds', u'value': 3600} |$ w- a7 Z/ i+ w0 I9 o" {5 [0 {. q
  | Name                          | ipsecpolicy1                           |  p3 d& P% q9 R# A7 s
  | Perfect Forward Secrecy (PFS) | group5                                 |
. G$ p+ W! p0 p" n6 Q. p2 N( y  | Project                       | 095247cb2e22455b9850c6efff407584       |- k( C1 _/ d9 L
  | Transform Protocol            | esp                                    |2 U5 t' [& N/ {! m/ B
  | project_id                    | 095247cb2e22455b9850c6efff407584       |
$ P% u: K/ e  P. J  y& X0 v7 ~- r( t( O  +-------------------------------+----------------------------------------+: H" C! d4 `9 F" X
Create a VPN service:2 s7 p# j$ A+ l
$ openstack vpn service create vpn \
/ R8 @+ J7 {+ W" F3 _+ C  --router 66ca673a-cbbd-48b7-9fb6-bfa7ee3ef724 \
" e, U. e' v8 b( ?6 {  --subnet cdfb411e-e818-466a-837c-7f96fc41a6d93 N; u1 i+ c- j# Z2 K( x
  +----------------+--------------------------------------+
' z- x! ?  T  L, k# h+ w  | Field          | Value                                |- m3 b/ C  V0 f5 }5 b' B- S
  +----------------+--------------------------------------+1 l9 b; v1 O" w$ K1 c+ z
  | Description    |                                      |0 \4 s+ F( u1 ^1 J$ R8 j
  | Flavor         | None                                 |
, T" R% }; `& a7 Z+ O  | ID             | 79ef6250-ddc3-428f-88c2-0ec8084f4e9a |  }4 p0 _% {1 u  P+ u
  | Name           | vpn                                  |
  ?( X7 h/ E3 @% G% r/ s  | Project        | 095247cb2e22455b9850c6efff407584     |8 ?: K& ^) {+ s! Z* e
  | Router         | 66ca673a-cbbd-48b7-9fb6-bfa7ee3ef724 |3 \- b+ W' E2 |* A6 I
  | State          | True                                 |
+ ]1 s) p) a0 E) N1 C  | Status         | PENDING_CREATE                       |
5 N8 N7 @' ~# }" k2 t; x1 |" T; D  | Subnet         | cdfb411e-e818-466a-837c-7f96fc41a6d9 |, `. f/ e8 }7 M+ p
  | external_v4_ip | 192.168.20.2                         |0 U( g: V( }4 N" P, c) o
  | external_v6_ip | 2001:db8::d                          |: m3 p1 n1 w* g( T8 @+ p' _
  | project_id     | 095247cb2e22455b9850c6efff407584     |
( z3 _- L" W: P/ a. q+ d# z  +----------------+--------------------------------------+
* x- N. o+ E/ ? Note6 ~; k, U7 o6 D  w
The --subnet option is required in this scenario.
& x3 K. U( T" KCreate an ipsec site connection:& g4 ~9 x5 ?  s8 G  w. B) R% i9 \
$ openstack vpn ipsec site connection create conn \! t4 v. o+ [; x8 G- T3 N- o
  --vpnservice vpn \0 k; ?% L& h1 }: C/ P( q6 _# ~
  --ikepolicy ikepolicy1 \" F" y7 X$ A/ A( l& J  `+ I* }* `: _
  --ipsecpolicy ipsecpolicy1 \
. J4 a& B  A. O' ^% ]5 _2 S* S  --peer-address 192.168.20.11 \9 [1 m; Z/ `6 d6 O" n! }' `
  --peer-id 192.168.20.11 \
) i4 I5 ?3 W3 j9 D) U8 t  --peer-cidr 192.168.1.0/24 \0 D7 E# O( J2 l, w  B
  --psk secret
) N3 Z9 x9 O8 d& m3 z' U9 v  +--------------------------+--------------------------------------------------------+
- m, f' m( R- B$ p) T1 y- j  | Field                    | Value                                                  |/ i5 ?7 {, ^, Y3 ^: I
  +--------------------------+--------------------------------------------------------+1 d* g7 j5 H& c+ i  S5 e6 V2 W4 H
  | Authentication Algorithm | psk                                                    |
! |. ^) g! g- ]3 y6 a& m  | Description              |                                                        |
/ N9 I  H' G3 n4 a" [  | ID                       | 5b2935e6-b2f0-423a-8156-07ed48703d13                   |
' X8 H% V5 H' S; w; `, L  | IKE Policy               | 99e4345d-8674-4d73-acb4-0e2524425e34                   |
5 z& H0 ?) u5 s2 ]  | IPSec Policy             | e6f547af-4a1d-4c28-b40b-b97cce746459                   |
/ M. b% p+ ~) M1 c) g( D  | Initiator                | bi-directional                                         |
6 n; ^4 d# t0 V7 p/ H  | Local Endpoint Group ID  | None                                                   |$ w8 }$ |! x1 Q
  | Local ID                 |                                                        |  z/ G1 ]4 R6 r; N
  | MTU                      | 1500                                                   |  g) y* N3 M) y$ m1 Y9 L
  | Name                     | conn                                                   |- B/ [8 O* N: x
  | Peer Address             | 192.168.20.11                                          |+ h; W& u% X( ^0 p" l$ R  c
  | Peer CIDRs               | 192.168.1.0/24                                         |' _$ e8 N. P  ^
  | Peer Endpoint Group ID   | None                                                   |
* S$ I$ z9 D9 v  | Peer ID                  | 192.168.20.11                                          |8 \2 N$ U; V# b: K
  | Pre-shared Key           | secret                                                 |7 ]2 {8 h( P+ O" O* _
  | Project                  | 095247cb2e22455b9850c6efff407584                       |7 v' z& }% _0 ?- J  W  A, q' P  ^* t
  | Route Mode               | static                                                 |4 ~; {$ \/ c7 |1 |
  | State                    | True                                                   |
! r3 p: l! e& B6 [9 S1 }  | Status                   | PENDING_CREATE                                         |: I/ R; @$ h$ K7 Z' S; {
  | VPN Service              | 79ef6250-ddc3-428f-88c2-0ec8084f4e9a                   |2 c6 L. K/ b+ z. c! g% W
  | dpd                      | {u'action': u'hold', u'interval': 30, u'timeout': 120} |
* {& M- q* V% ~  | project_id               | 095247cb2e22455b9850c6efff407584                       |9 v& K/ Q# G# }) x1 [
  +--------------------------+--------------------------------------------------------+
7 R8 A# d5 b; l9 q9 b9 N3 l Note! t& H+ F: |& H
Please do not specify --local-endpoint-group and --peer-endpoint-group options in this case.
2 A% k1 o4 g; m5 C. ]+ z+ D3 a1 x+ k8 L( p

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-26 10:17:48 | 显示全部楼层
Installation5 R! s2 `, }( j( Q, I' @! s! \. P
In order to use Neutron-VPNaaS with devstack (http://devstack.org) a single node setup, you'll need the following settings in your local.conf (NEW: neutron-vpnaas plugin is added).
7 C# y. ?9 X7 P% B# t, ^% D3 C. f' Y0 G3 W
[[local|localrc]]
" |0 q% h# m' u. l" T, z+ H& `1 h4 V  O
enable_plugin neutron-vpnaas https://git.openstack.org/openstack/neutron-vpnaas4 f- d+ j9 c! I' v. G* J9 |

& }" h) w+ e& ^5 Udisable_service n-net
* M0 l( P% h" N* S9 Renable_service q-svc" Y2 G. t9 s" V: l2 i, d% o
enable_service q-agt. o3 }9 g8 m- O* }' k. _4 }8 d
enable_service q-dhcp- u( B0 @9 K+ G; r
enable_service q-l3' x0 [* A1 W' U- `) w# f: y3 t- D
enable_service q-meta5 x+ w- q- m: M
# Optional, to enable tempest configuration as part of devstack
/ g" j3 @. D5 P5 J- b! oenable_service tempest
" {& N- t5 `+ u( `" z, p: o& q4 P, `% S+ A" P3 j( o) v
# IPSec driver to use. Optional, defaults to OpenSwan.1 ?6 E' B5 h( u' b& ?4 Y9 \5 Q5 y2 l
IPSEC_PACKAGE="openswan"3 g. E0 A! p9 L0 R# @2 K! Q
Quick Test Script
- M6 M. y+ \$ u$ ^0 uhttp://paste.openstack.org/raw/44702/0 f2 k/ i5 L0 t. Z8 y3 I
; p( W! h3 J. s6 q0 E
This quick test script create two site with a router,a network and a subnet connected with public network. Then, connect both site via VPN.
+ [3 X3 a; O* H! l5 k
4 a% j3 g* u4 ~Using Two DevStack Nodes for Testing
! q) l' J# W9 `+ c4 TYou can use two DevStack nodes connected by a common "public" network to test VPNaaS. The second node can be set up with the same public network as the first node, except it will use a different gateway IP (and hence router IP). In this example, we'll assume we have two DevStack nodes (East and West), each running on hardware (you can do the same thing with multiple VM guests, if desired). (Note: you can also create similar topology using two virtual routers with one devstack)
' ]$ N2 `' B- ~9 z7 y. ~
, s; \3 R7 l1 N: }8 XExample Topology; ^' g) {2 y) A6 B% [* t
8 K/ i8 }1 F/ e$ X# _7 ]$ P1 I
A dedicated physical port can be used for the "public" network connection (e.g. eth2) interconnected by a physical switch. You'll need to add the port to the OVS bridge on each DevStack node (e.g. sudo ovs-vsctl add-port br-ex eth2).
0 a% s: t' y. A; O, s- C0 o% ]% V( u+ t( ^
      (10.1.0.0/24 - DevStack East)
+ }' Q  u- _2 j              |8 n2 k/ `: U& x" ^
              |  10.1.0.1' y2 a5 k# O& L+ _9 P: B8 r1 B" M
     [Neutron Router]
$ h8 B4 \% l+ S4 _              |  172.24.4.226$ i6 G; i, w: Z
              |6 \; |! l9 K4 ?4 F  m
              |  172.24.4.225' R8 U% w7 C1 y$ g# k, V, j, V
     [Internet GW]4 e& I5 x, R7 h$ e2 @; \( @3 n
              |  ( o9 e8 T) \  j2 Y7 v
              |
/ B- ~! @8 }  I+ k# p# {     [Internet GW]7 H" H8 }2 ^  w0 @) `
              | 172.24.4.2321 l" U0 {0 V2 s2 ~# W& x  H
              |
; l' @1 b( [  Z1 D" O; c" n- C              | 172.24.4.233
: s# N" r) M# I     [Neutron Router]
# Z+ H/ S7 Z$ b! |! _; c              |  10.2.0.1' J$ R/ x1 Z  C. M; \, a
              |' T/ T: z6 l' I
     (10.2.0.0/24 DevStack West): |. H4 W# L% A1 M. o! L
DevStack Configuration
/ l* o3 c" E9 v3 K6 D4 i" {  ]3 b
$ M1 K: R; N7 ~9 d$ K3 J, _For East you can append these lines to the localrc, which will give you a private net of 10.1.0.0/24 and public network of 172.24.4.0/24; v2 P( n  K2 X0 m

4 ?8 g1 a* y/ E+ z5 FPUBLIC_SUBNET_NAME=yoursubnet2 z8 h6 W2 G$ a' X) P  [8 ~
PRIVATE_SUBNET_NAME=mysubnet& l" T6 L& d8 U" a( D# z) L; V) i
FIXED_RANGE=10.1.0.0/249 N. i  S! a0 z9 S
NETWORK_GATEWAY=10.1.0.1; g4 y! F9 b' t- ?8 b# a
PUBLIC_NETWORK_GATEWAY=172.24.4.225
% p# _% X4 C( P% Z; I: F7 iQ_FLOATING_ALLOCATION_POOL=start=172.24.4.226,end=172.24.4.2319 ~' A! [/ h+ y0 [" j
For West you can add these lines to localrc to use a different local network, public GW (and implicitly router) IP:
' p3 U  D8 I, S4 ~( }1 A+ D3 \2 A, f# R2 U; w
PUBLIC_SUBNET_NAME=yoursubnet1 o) e: Z8 @% {9 E1 [7 H1 E& c
PRIVATE_SUBNET_NAME=mysubnet, X1 V8 s! F6 g. c- h8 Q* ^
FIXED_RANGE=10.2.0.0/24& D5 ^' s' R! y% U
NETWORK_GATEWAY=10.2.0.1, Q) N* D# n9 v1 ?  x+ n
PUBLIC_NETWORK_GATEWAY=172.24.4.232+ G$ u7 o$ \" P- V$ e9 Z7 R2 S- Z
Q_FLOATING_ALLOCATION_POOL=start=172.24.4.233,end=172.24.4.238
/ w* U4 H8 U# R  r9 E7 x0 V; S% f+ CVPNaaS Configuration' ]* K0 A0 ]1 J8 h+ S

$ X  s& @# ^4 D( ^; [0 z/ l0 S( [With DevStack running on East and West and connectivity confirmed (make sure you can ping one router/GW from the other), you can perform these VPNaaS CLI commands.
3 i0 V4 Y* G4 D# }, _0 `! J( _/ {2 F) v5 f0 N5 n' I( W- J5 ~/ o7 R+ u
On East
0 |8 S3 W8 n6 g5 w9 y# ]4 {: p% e2 o
neutron vpn-ikepolicy-create ikepolicy1! g3 |5 l5 q* d* [  a, I
neutron vpn-ipsecpolicy-create ipsecpolicy1. i4 I4 m& S2 M9 T3 o' @8 y
neutron vpn-service-create --name myvpn --description "My vpn service" router1 mysubnet8 R" q! o; Z1 `
neutron ipsec-site-connection-create --name vpnconnection1 --vpnservice-id myvpn --ikepolicy-id ikepolicy1 --ipsecpolicy-id ipsecpolicy1 --peer-address 172.24.4.233 --peer-id 172.24.4.233 --peer-cidr 10.2.0.0/24 --psk secret" v( c# r. K1 l. m+ _" I
On West
% \# s4 P3 E' ^6 A- _
% S) ~3 {2 p! y0 e& i& tneutron vpn-ikepolicy-create ikepolicy1
2 @) A: u/ f' g% n1 K6 o' v, Hneutron vpn-ipsecpolicy-create ipsecpolicy1/ [0 s/ H; l7 o' R1 i( e
neutron vpn-service-create --name myvpn --description "My vpn service" router1 mysubnet
' X7 l& V( j  W! X( U9 Q6 f, Nneutron ipsec-site-connection-create --name vpnconnection1 --vpnservice-id myvpn --ikepolicy-id ikepolicy1 --ipsecpolicy-id ipsecpolicy1 --peer-address 172.24.4.226 --peer-id 172.24.4.226 --peer-cidr 10.1.0.0/24 --psk secret3 W3 b! a5 h; c6 M
Note: Please make sure setup security group (open icmp for vpn subnet etc)
  H5 B' m) \& q" U! E$ D. f8 y1 r
6 I5 S& S1 i! F  q7 p1 w; E6 N3 _$ fVerification% o# n3 h' E& s& Y& M, G

7 ]' {$ t. M1 I! _' HYou can spin up VMs on each node, and then from the VM ping the far end router's public IP. With tcpdump running on one of the nodes, you can see that pings appear as encrypted packets (ESP). Note that BOOTP, IGMP, and the keepalive packets between the two nodes are not encrypted (nor are pings between the two external IP addresses).  A6 I" P% M+ I4 s$ J9 z! r
, e; Y' ?9 S7 }) a0 r8 }5 W
Kilo Update& c" A2 K& h* o9 e. Y9 B8 X9 W

+ O) Y" f; O$ p: m# K1 ~+ oFor Kilo, the localrc contents was moved into local.conf. With (VirtualBox) VMs used as hosts, where eth0 was set up as NAT, and eth1 set up as Internal Network, the following configurations were used in local.conf:' Z4 D7 c6 e& Q1 t5 T
( W+ O& i5 N7 _& l5 ^) l
   OVS_PHYSICAL_BRIDGE=br-ex8 t* K* e  U# ]* Z
   PUBLIC_INTERFACE=eth1
- |  P/ o5 U8 M, OOnce stacked, VMs were created for testing, VPN IPSec commands used to establish connections between the nodes, and security group rules added to allow ICMP and SSH.' |  x: T3 F& W. G+ V' F$ {* R
2 l" h( O( _" b1 J$ x% D
VPNaaS with Single DevStack and Two Routers
0 s; ?, v6 |& R4 ?9 ?* }Simple instructions on how to setup a test environment where a VPNaaS IPSec connection can be established using the reference implementation (OpenSwan). This example uses VIrtualBox running on laptop to provide a VM for running DevStack. It assumes a Kilo release (post Juno).
8 A0 \" f* y1 ?1 H6 o' t6 j( S0 q7 m9 }& H
The idea here is to have a single OpenStack cloud created using DevStack, two routers (one created automatically), two private networks (one created automatically) -10.1.0.0/24 and 10.2.0.0/24, a VM in each private network, and establish a VPN connection between the two private nets, using the public network (172.24.4.0/24).# p9 P( U/ U& U8 I% _: y

% w4 P& J8 A9 j& v5 Q( }Preparation; `8 v/ X& Q5 T0 J/ C
Create a VM (e.g. 7 GB RAM, 2 CPUs) running Ubuntu 14.04, with NAT I/F for access to the Internet. Clone a DevStack repo with latest (Kilo-1 used for this example).3 J6 T# V( z/ @' O/ E$ T8 l
+ F( F0 Z/ M7 W1 C4 {" O0 z2 m
DevStack Configuration
$ V* b! |$ ?# K0 T! X. S2 WFor this example, the following local.conf is used:5 |3 D7 N' F8 ^" r4 I% O

- S$ j8 F6 A  f   localrc# H7 U! N. p# y& m( M
   GIT_BASE=https://github.com! n9 ?+ ^* j! m+ n% L3 U) R( \; q, f
   DEST=/opt/stack
2 V, b$ u: l$ Q3 \4 J   8 ]: A& X4 {, T& N& K9 A
   disable_service n-net
# z. ^% {* g; P# t; u2 S4 V   enable_service q-svc  g" k3 L' `7 B- L. G
   enable_service q-agt' }/ D2 A0 B2 ^  e  e( g9 u- L, X
   enable_service q-dhcp
- S. I5 ]& |7 y2 J/ [   enable_service q-l3% h, ]' Y1 f+ X" N% W; w
   enable_service q-meta) h: Z' ~6 i- G4 h
   enable_service neutron$ t& r; ~7 D) [" L! v
   enable_plugin neutron-vpnaas https://git.openstack.org/openstack/neutron-vpnaas
5 ^% w2 g* [3 F  b$ {, P   ! H; g  {, \+ E5 Z
   FIXED_RANGE=10.1.0.0/24& b/ Z! s: V2 d6 L7 N* f
   FIXED_NETWORK_SIZE=256
: Z) f8 N* ^/ T( N   NETWORK_GATEWAY=10.1.0.1
* e& F: }4 @" k8 a0 E4 ~7 Z   PRIVATE_SUBNET_NAME=privateA$ \) u5 B2 E8 x& R
   
5 G* [- Z  V( e   PUBLIC_SUBNET_NAME=public-subnet' F2 C: _$ R* \
   FLOATING_RANGE=172.24.4.0/24+ p8 Q; K0 w8 e5 q% o2 B  R- t7 B
   PUBLIC_NETWORK_GATEWAY=172.24.4.10
  w+ I% O1 R/ }$ Y   Q_FLOATING_ALLOCATION_POOL="start=172.24.4.11,end=172.24.4.29"7 N. r  F( c6 m) X
   : s. C8 O% M" [% K# r7 k, W& F. d8 w
   LIBVIRT_TYPE=qemu- @5 Q, L, r$ M
   
  \; k" N$ Q: v$ p0 w! F   IMAGE_URLS="http://cloud-images.ubuntu.com/releases/14.04.1/release/ubuntu-14.04-server-cloudimg-amd64.tar.gz,http://download.cirros-cloud.net ... 3-x86_64-uec.tar.gz": w+ y* {7 R$ j- V' D1 O3 H
   3 e* Z5 v" H3 U
   SCREEN_LOGDIR=/opt/stack/screen-logs
% s7 |) I9 m" N8 U0 ]+ j7 Y   SYSLOG=True$ j) C( z- X- L2 N  \& N: X
   LOGFILE=~/devstack/stack.sh.log* c, x9 p" W0 Y. @5 x4 c6 Q  W% P- _
   * S: |: c/ z: {) ~- `7 t- \$ q
   ADMIN_PASSWORD=password
; s9 l8 u! d: B% `3 U   MYSQL_PASSWORD=password
& y6 h+ |, [% ^, G/ O/ [   RABBIT_PASSWORD=password& ]) Y4 O+ j3 D6 i# i
   SERVICE_PASSWORD=password
4 U5 _8 _9 u1 ?- p6 J8 t   SERVICE_TOKEN=tokentoken
) m1 J* h5 H* z   1 M' \  i: O0 y7 }9 o1 `, U
   Q_USE_DEBUG_COMMAND=True
& p3 }* d9 j0 T4 r   ) [2 E( e1 b9 Q2 I( V! y
   # RECLONE=No$ C( G  E" ]2 a/ D% O$ @. X: s
   RECLONE=yes+ A# w% q+ q% e- {5 p, J8 r2 P) o
   OFFLINE=False
' p, g* D% m5 C/ PStart up the cloud using ./stack.sh and ensure it completes successfully. Once stacked, you can change RECLONE to No.# Y1 j4 D! w" G! W8 F5 l

& P: ?! G) V5 z5 b& d( z+ y( KCloud Configuration
7 C4 `: D" u5 l% Z' B% f( SOnce stacking is completed, you'll have a private network (10.1.0.0/24), and a router (router1). To prepare for establishing a VPN connection, a second network, subnet, and router needs to be created, and a VM spun up in each private network.1 e$ l3 D# U5 y6 x: J' f5 g
% F3 p8 r* J: c  j9 f
   # Create second net, subnet, router2 C- r$ B- e0 t" b$ `# ?0 \# ]) C
   source ~/devstack/openrc admin demo
9 K! m8 t2 {! k0 c( l   neutron net-create privateB
( G7 H/ d: m* N: i   neutron subnet-create --name subB privateB 10.2.0.0/24 --gateway 10.2.0.1* d# T# u3 T8 n3 q1 f" p$ o
   neutron router-create router2* B4 f8 s+ R9 T8 J- B
   neutron router-interface-add router2 subB
: _7 u4 U( j) Q% U: u   neutron router-gateway-set router2 public4 B. ?4 S$ |( E
   ! ^8 N& w6 o9 s: Q  k5 r$ [: ?: Z7 h
   # Start up a VM in the privateA subnet.( T+ d! E6 a6 S0 x4 \
   PRIVATE_NET=`neutron net-list | grep 'private ' | cut -f 2 -d' '`' A: v3 u# B8 b$ q& d
   nova boot --flavor 1 --image cirros-0.3.3-x86_64-uec --nic net-id=$PRIVATE_NET peter
; _6 O) j) M* P& K4 F4 [; u0 Q   
5 h2 h! d% C! d* u4 Q   # Start up a VM in the privateB subnet
8 d& P! D" A, D- Y! x   PRIVATE_NETB=`neutron net-list | grep privateB | cut -f 2 -d' '`
: f4 d+ L/ m$ L: j! i7 e3 T! K0 U, p. I& f   nova boot --flavor 1 --image cirros-0.3.3-x86_64-uec --nic net-id=$PRIVATE_NETB paul5 d, X: L6 m# c9 C# j  G
At this point, you can verify that you have basic connectivity. Note, DevStack will create a static route that will allow you to ping the private I/F IP of router1 from privateB network. You can remove the route, if desired.7 N8 c5 T6 X7 s
5 r9 V5 h) n+ U+ s/ Y
IPSec Site-to-site Connection Creation7 R6 ^$ Y1 y6 ^& L$ i$ Q" x" n9 D1 l
The following commands will create the IPSec connection:5 q; C( U6 n' t1 [: i) E7 }+ i

/ Q( h( T4 a. l. `/ F   # Create VPN connections! D. C0 g6 W) D4 a0 u+ K, I9 N
   neutron vpn-ikepolicy-create ikepolicy
& i! D8 a4 j+ r, r: K( i   neutron vpn-ipsecpolicy-create ipsecpolicy0 z) T) s% T1 ~' |# x( `! u+ g0 C
   neutron vpn-service-create --name myvpn --description "My vpn service" router1 privateA3 @6 s# y5 D1 h" n# }: L
   ! _; j# ]$ }+ Y
   neutron ipsec-site-connection-create --name vpnconnection1 --vpnservice-id myvpn \7 p* }* l6 f1 |6 o0 b8 M' o
   --ikepolicy-id ikepolicy --ipsecpolicy-id ipsecpolicy --peer-address 172.24.4.13 \
% x( Y3 c/ f0 @0 x   --peer-id 172.24.4.13 --peer-cidr 10.2.0.0/24 --psk secret
: ^, X) w0 t/ |6 H4 C/ p( V   ' ^9 q; q9 Q2 f. K0 F% T8 g' X; M
   neutron vpn-service-create --name myvpnB --description "My vpn serviceB" router2 subB6 c8 M1 }! y. Y: m3 {  z8 K; V! K
   " S8 X9 F# D# }5 ~
   neutron ipsec-site-connection-create --name vpnconnection2 --vpnservice-id myvpnB \
3 Y- r7 T4 Z- A! y! N   --ikepolicy-id ikepolicy --ipsecpolicy-id ipsecpolicy --peer-address 172.24.4.11 \
- |; r& L* G% q4 q   --peer-id 172.24.4.11 --peer-cidr 10.1.0.0/24 --psk secret) ^+ ]! O. R* S4 n6 V
At this point (once the connections become active - which can take up to 30 seconds or so), you should be able to ping from the VM in the privateA network, to the VM in the privateB network. You'll see encrypted packets, if you tcpdump using the qg-# interface from one of the router namespaces. If you delete one of the connections, you'll see that the pings fail (if all works out correctly :).( W1 U  V- I- X# Z: y1 t

# D% m' h- K* w8 Y# NMultiple Local Subnets& i* v1 v( L0 n
Early in Mitaka, IPSec site-to-site connections will support multiple local subnets, in addition to the current multiple peer CIDRs. The multiple local subnet feature is triggered by not specifying a local subnet, when creating a VPN service. Backwards compatibility is maintained with single local subnets, by providing the subnet in the VPN service creation.$ b. d3 L  L3 G3 i2 L* o
. p3 R/ ^; b) t1 X: f, S9 }
To support multiple local subnets, a new capability has been provided (in Liberty), called "Endpoint Groups". Each endpoint group will define one or more endpoints of a specific type, and can be used to specify both local and peer endpoints for IPSec Connections. The Endpoint Groups separate the "what gets connected" from the "how to connect" for a VPN service, and can be used for different flavors of VPN, in the future. An example:
  c) M5 j7 r* m" a9 G1 S/ b  t
3 }' v& N; {& y& e/ a+ T! w1 j/ e   # Create VPN connections
% v) n0 A8 y6 |2 ~  v   neutron vpn-ikepolicy-create ikepolicy
* @% D" x' K; J) c* O   neutron vpn-ipsecpolicy-create ipsecpolicy
% E" h8 \, C# O; c   neutron vpn-service-create --name myvpnC --description "My vpn service" router13 C" Z3 @* j3 f" U0 u
To prepare for an IPSec site-to-site, one would create an endpoint group for the local subnets, and an endpoint group for the peer CIDRs, like so:
5 C: Y* J4 Q; N1 i8 R% z# K# x  g: F: G7 q3 D6 p# A! O
   neutron vpn-endpoint-group-create --name my-locals --type subnet --value privateA --value privateA2
% S6 d2 S; U+ x3 U6 K3 {   neutron vpn-endpoint-group-create --name my-peers --type cidr --value 10.2.0.0/24 --value 20.2.0.0/24# u7 M0 h5 j7 _2 o2 X( A- }% ?
where privateA and privateA2 are two local (private) subnets, and 10.2.0.0/24 and 20.2.0.0/24 are two CIDRs representing peer (private) subnets that will be used by a connection. Then, when creating the IPSec site-to-site connection, these endpoint group IDs would be specified, instead of the peer-cidrs attribute:
' F! ]/ M( F- e) g4 D
  d( r" W  W6 A: v' G; j' U   neutron ipsec-site-connection-create --name vpnconnection3 --vpnservice-id myvpnC \2 {. L, G) p- F6 N: c
   --ikepolicy-id ikepolicy --ipsecpolicy-id ipsecpolicy --peer-address 172.24.4.11 \2 B! c( V$ C6 n
   --peer-id 172.24.4.11 --local-ep-group my-locals --peer-ep-group my-peers --psk secret
/ N6 _6 ~7 w3 p% G5 A8 C$ o8 w7 oNotes:
7 b* c0 R8 x- o# l3 o, |+ v
) @& x/ c3 F9 B- D0 K  E- RThe validation logic makes sure that endpoint groups and peer CIDRs are not intermixed.- i0 v7 b% C! ~) N2 f
Endpoint group types are subnet, cidr, network, router, and vlan. However, only subnet and cidr are implemented (for IPSec use).
0 e: c3 C2 ^3 ~" PThe endpoints in a group must be of the same type, although can mix IP versions.; I6 [- D( L1 x  ~; W+ K- t
For IPSec connections, validation currently enforces that the local and peer endpoints all use the same IP version.
3 K; W# |7 I/ r$ GIPSec connection validation requires that local endpoints are subnets, and peer endpoints are CIDRs.
5 N% k6 J, g( W% iMigration will convert information for any existing VPN services and connections to endpoint groups.
$ z3 f3 ]3 B8 I' wThe original APIs will work for backward compatibility.
9 {: L& A5 i5 z! H, f# x1 Y2 Z5 |Horizon Support% @5 |2 |  r# |' i5 j
Checkout Test branch
* o; n' ?- `; x; r( J/ _3 }Horizon support has been merged.  i# z0 I4 Q. ?6 X% Y! _7 s
6 U) V+ n# s& k5 q# z
Enable VPN section in Horizon1 a4 H) D4 u( D0 g5 o+ ]
Note that ff q-vpn is enabled Horizon VPN support is enabled automatically.- [: z' V! W7 U9 A7 X

2 F8 P8 Q/ J$ |! yOpen4 d% y9 U7 n- q& {# A/ ]5 i
/opt/stack/horizon/openstack_dashboard/local/local_settings.py
+ d; O# [/ W! p0 J$ x. s1 Kand replace# l/ _6 B2 F: P5 M) l2 s
2 j; L1 s. j) r* O* N7 Q6 S8 p7 l
OPENSTACK_NEUTRON_NETWORK = {9 G0 S! X) a- h1 R
    'enable_vpn': False,' h# R' M; k# ^+ W9 l
}
1 ?1 \9 p/ H/ c# hwith
# C, \  Y8 T% d$ X* |1 T5 K+ }5 _5 e
OPENSTACK_NEUTRON_NETWORK = {2 f( J; c8 P9 w- T6 o+ |* I
    'enable_vpn': True,
2 l% F# w  E  o- V& M% q( r}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 04:26 , Processed in 0.021372 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表