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

neutron ipsecvpn create step

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2019-4-26 10:09:31 | 显示全部楼层 |阅读模式
3 e, X6 ^4 c3 g4 S5 G. K+ i
$ {) t6 N+ v" Q  A2 b/ M9 R( p: e
以下为手动编写这个文件:
5 W8 }9 V/ N9 E0 \5 D1 t: ^cd /usr/share/openstack-dashboard/openstack_dashboard/enabled/
& J! B' I- x; T; K" `4 j& v/ Itouch _7100_project_vpn_panel.py- M8 h: \+ i& x% g' U+ [3 ?
文件内容如下:7 w. _' |, o8 X) E; M: Z: W
[root@localhost enabled]# vim _7100_project_vpn_panel.py* z9 h# ~& A+ \4 Y) W5 m! l4 w
# Licensed under the Apache License, Version 2.0 (the "License"); you may1 D: Q3 i, I3 r* u9 M$ j
# not use this file except in compliance with the License. You may obtain: N: L# |$ x+ j3 r$ ]
# a copy of the License at
) x, f$ d; H) J5 e7 D, C. Y7 O' F#0 C4 P* L& E* V
# http://www.apache.org/licenses/LICENSE-2.0
# P' Q# `0 n' c9 A7 m#2 {! w5 z4 c3 m. I" V# T0 H6 B0 S- |
# Unless required by applicable law or agreed to in writing, software
. @9 h) `6 z! U& q# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT" ?0 m$ {$ V# I
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
. W" ^. x% C/ j! T2 f$ G# License for the specific language governing permissions and limitations
" n& d+ R' K5 }! @, j# under the License.( A+ `3 N; h! B+ E+ t
% _" @! d+ P" z* k
# The slug of the panel to be added to HORIZON_CONFIG. Required.- M' R5 ?# l* \) X
PANEL = 'vpn'+ L( p0 F; Z  Q
# The slug of the dashboard the PANEL associated with. Required.
( f7 o* R" }! j( JPANEL_DASHBOARD = 'project'; \3 A, @1 K/ W& E2 [8 T
# The slug of the panel group the PANEL is associated with.3 u: U, M( A& p! T4 P, D( \
PANEL_GROUP = 'network'2 S4 e/ z$ f# e  G! f9 z3 P* }
1 Y+ B4 ~1 g) i* A1 g
# Python panel class of the PANEL to be added.
- a0 {( @/ \/ TADD_PANEL = 'neutron_vpnaas_dashboard.dashboards.project.vpn.panel.VPN'; S6 s4 }& d8 g. G$ u( {

8 g1 }% `: p- d, A$ V- q- w  IADD_INSTALLED_APPS = ["neutron_vpnaas_dashboard"]& [1 S" \4 p  |8 s+ i2 D/ y6 l5 z2 c
+ I% k* ?5 I  w  j; J

, C% t: K& y+ A- c8 ]- j1 d4.1 vim /etc/neutron/neutron.conf
6 t6 V! X' H1 i1 d5 Z[DEFAULT]
) Z, A6 r! b, H: Fservice_plugins = router,vpnaas( X- }4 }% H# C' A9 O+ M

% e% M2 o+ ]6 f2 z& P4 e$ J; r4.2 vim  /etc/neutron/neutron_vpnaas.conf
- r2 e7 P& p& o. o: |0 r7 o[service_providers]
3 P" U- r, R. d8 D$ Sservice_provider = VPN:strongswan:neutron_vpnaas.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default( u. X" M4 z. ^& m! z
$ {6 U8 o' @% Y" o7 g8 H. V
4.3 vim /etc/neutron/l3_agent.ini& V. S7 E9 a5 o9 A# u: ^
[agent]
- R. }) ?$ `  ~extensions = vpnaas
$ K  D  N: e' r' R9 I0 \3 p/ W[vpnagent]
/ p, m2 N0 S& J2 @" w3 i0 {! Dvpn_device_driver = neutron_vpnaas.services.vpn.device_drivers.strongswan_ipsec.StrongSwanDriver
0 H4 L$ P. |5 E! Z
3 N$ a% T8 A& S3 C. Y4.4 执行 neutron-db-manage --subproject neutron-vpnaas upgrade head* _! S; r1 f( d; l0 ?: }

+ q" w9 y# z, y5. 重启服务
7 n8 G: t4 g' `1 h% b5 Vsystemctl restart neutron-server
" \: h6 B  L3 e/ a2 m7 ]systemctl restart neutron-l3-agent8 l# w. X# T5 H4 e- G
systemctl restart apache2
, L. `8 a4 m. M4 n, z, W( \--------------------- ) }+ F  l5 B- B# ]/ g
9 t( G+ u- S0 i3 k% [+ b

! R8 d6 q" M# _3 d* M
) ~! l% x9 M# a/ o7 m2 t" {1 CVirtual Private Network-as-a-Service (VPNaaS)
. {" H9 r1 J" s/ V8 w, s  D  
, s3 f! T2 C6 ^/ r: L+ qTHIS PAGE LAST UPDATED:
; P+ S- S( e# |9 B6 F" ~Enabling VPNaaS¶1 [5 F, U& W* O! c; ?% b7 i0 Q
This 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.
0 K  N: H# Q6 _: G6 TEnable the VPNaaS plug-in in the /etc/neutron/neutron.conf file by appending vpnaas to service_plugins in [DEFAULT]:
) [! Q" E' K( T+ C; G; P[DEFAULT]
/ v: q1 D- \+ U# ...0 F1 t; G+ y3 p. O
service_plugins = vpnaas
3 v5 }! X8 A; k) P9 ^" I) H Note. y' q. s$ N5 B6 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.
3 Y; O) Q% d. C2 K) xConfigure the VPNaaS service provider by creating the /etc/neutron/neutron_vpnaas.conf file as follows, strongswan used in Ubuntu distribution:( c$ A. M9 U7 N9 ^7 u! v) A+ {
[service_providers]$ r/ J% D- `2 r/ V- s/ o, P9 N: \
service_provider = VPN:strongswan:neutron_vpnaas.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default. x5 u/ ?; a  i' Y7 g. f
Note
5 D/ y8 h! K! I8 \4 P* S# W6 kThere 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.
% K" M; x, U/ P0 uConfigure the VPNaaS plugin for the L3 agent by adding to /etc/neutron/l3_agent.ini the following section, StrongSwanDriver used in Ubuntu distribution:
1 g2 P; K/ N8 S' l( V* N0 Q( ]8 T[AGENT]' V# P2 Z& W. F& I+ z
extensions = vpnaas
; x: B9 l0 E1 _9 J$ K2 H) q[vpnagent]
7 D+ s' Z/ U5 B1 Avpn_device_driver = neutron_vpnaas.services.vpn.device_drivers.strongswan_ipsec.StrongSwanDriver/ U$ x" i+ q, ^$ N; G
Note' ?- ~# q1 p7 W) ]- _# A" h- l# p+ C6 h
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." @  k+ [8 P, P' t! W& U
Create the required tables in the database:  f. b, ]( ?; x* P  o  k
# neutron-db-manage --subproject neutron-vpnaas upgrade head
2 v6 S3 z% ]4 b+ i+ e: V" i3 S Note
* D8 u- k: S7 n- _7 }( FIn order to run the above command, you need to have neutron-vpnaas package installed on controller node.( k5 n" [& M% o% \  ]( S9 j* u
Restart the neutron-server in controller node to apply the settings.$ I1 X6 m2 I' V5 P8 I
Restart the neutron-l3-agent in network node to apply the settings.
- {& z. @& Q( j3 A/ l: CUsing VPNaaS with endpoint group (recommended)¶
7 I- f- J' o$ W* e/ o$ n  j. P* kIPsec 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.9 [( ^& M0 I; c8 I: H
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.
# M* a+ n3 w- WRefer Multiple Local Subnets for more detail.
, g- a$ c  o8 ^& {$ o$ q, FCreate 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.
& }/ e- f1 }$ R6 g* V% T7 ICreate an IKE policy:
* x: h8 |6 i) C9 n0 B$ openstack vpn ike policy create ikepolicy9 K5 K3 l. R: R6 @( O. s
  +-------------------------------+----------------------------------------+/ U, d, m) H' W! p( `
  | Field                         | Value                                  |
0 Y" K; p- x) |  {' f* \  +-------------------------------+----------------------------------------+2 u: O( ^' @0 d9 k/ U! ]
  | Authentication Algorithm      | sha1                                   |
, i. ~0 w6 \/ n) Y- J! A- f  | Description                   |                                        |+ A/ n8 l" c7 \: q3 H
  | Encryption Algorithm          | aes-128                                |
) S9 g( y1 R4 O. ~  | ID                            | 735f4691-3670-43b2-b389-f4d81a60ed56   |
* e0 ^, ?* S2 z5 s0 W0 k/ o  | IKE Version                   | v1                                     |$ u5 z+ o& i8 q( l
  | Lifetime                      | {u'units': u'seconds', u'value': 3600} |3 ~$ f+ h$ Q6 }' X1 k' F! B
  | Name                          | ikepolicy                              |
; A* U: F& ]$ q6 E3 |8 X! q  | Perfect Forward Secrecy (PFS) | group5                                 |$ t$ _/ V8 c( S3 k; G! V$ W' u
  | Phase1 Negotiation Mode       | main                                   |
; l7 |- w3 T7 k7 N- P( x7 S  | Project                       | 095247cb2e22455b9850c6efff407584       |
; o6 T) d  w: C( E  S# S  | project_id                    | 095247cb2e22455b9850c6efff407584       |; X- ~. v2 m$ T9 c) a8 R( n& v
  +-------------------------------+----------------------------------------+
" P  c9 [( Q  ~) a4 z$ ^1 W4 ]Create an IPsec policy:: F6 l6 m% ?& f6 b2 V" M
$ openstack vpn ipsec policy create ipsecpolicy
3 c4 E& a$ a5 t: l: E0 d  +-------------------------------+----------------------------------------+
0 B  N' k5 \* C$ n, |6 j  | Field                         | Value                                  |$ Q$ Z+ n4 y  a* p) }  X% ?
  +-------------------------------+----------------------------------------+/ J% K( W) `' @) P% l) P% C9 c* L
  | Authentication Algorithm      | sha1                                   |; r/ f5 I+ I% v7 r9 M7 n0 j' h- i
  | Description                   |                                        |5 z; p5 @7 Y" g2 \, E( ^
  | Encapsulation Mode            | tunnel                                 |# Z" f8 Z& p( Z7 E
  | Encryption Algorithm          | aes-128                                |
- E) g1 ?# Q# S7 Y2 s  | ID                            | 4f3f46fc-f2dc-4811-a642-9601ebae310f   |
0 ]' ?( k( G0 K; I9 m  | Lifetime                      | {u'units': u'seconds', u'value': 3600} |- J4 Y' v4 y9 A' U
  | Name                          | ipsecpolicy                            |2 C4 R4 ^3 ^9 [
  | Perfect Forward Secrecy (PFS) | group5                                 |
, y8 `2 Y4 ]! S9 d5 a9 f* D/ I  | Project                       | 095247cb2e22455b9850c6efff407584       |
2 Q' _# L/ m) T& @; p, b4 a0 p8 K  | Transform Protocol            | esp                                    |
' E& j0 I+ @3 C, i5 ^# @- ?5 O  | project_id                    | 095247cb2e22455b9850c6efff407584       |. s2 l" f0 M* _* E
  +-------------------------------+----------------------------------------+5 m7 N, ?6 D3 a" D& V  _
Create a VPN service:3 [5 z: A, P2 z8 `! a
$ openstack vpn service create vpn \
0 C" h& h5 u# Q8 }! {3 H  --router 9ff3f20c-314f-4dac-9392-defdbbb36a664 c/ ]* K3 M8 ?; z1 h) a
  +----------------+--------------------------------------+" c! C( G. i3 T8 Z
  | Field          | Value                                |6 r% W  d7 W2 x. N3 n' ~/ e4 i
  +----------------+--------------------------------------+6 T: J3 ~" p* l' T4 _# |
  | Description    |                                      |) D: H: J+ C4 W+ ?, m( q
  | Flavor         | None                                 |
# H* {, O" \( Y0 |2 A: _5 A  | ID             | 9f499f9f-f672-4ceb-be3c-d5ff3858c680 |  v' k& }2 p/ K) p
  | Name           | vpn                                  |
# u. H0 L; ]" N6 k! h, \  | Project        | 095247cb2e22455b9850c6efff407584     |* Y, A$ ?& e+ c5 @5 C/ @
  | Router         | 9ff3f20c-314f-4dac-9392-defdbbb36a66 |
" p$ N, W# b2 V2 L, q$ \) x  | State          | True                                 |7 p8 L0 }: l* O6 w. F% a) K. _
  | Status         | PENDING_CREATE                       |
8 r4 b6 D$ A( u2 \9 m* e3 M( Y/ F  | Subnet         | None                                 |
$ b% Q# t: P; m4 f2 F1 }" Q( D  | external_v4_ip | 192.168.20.7                         |
' X4 q$ K: F! b5 O; }7 u  | external_v6_ip | 2001:db8::7                          |
* V+ l, s) c# W9 n  | project_id     | 095247cb2e22455b9850c6efff407584     |
2 X+ K% F- o. K0 s0 q  +----------------+--------------------------------------+6 `% B# ^( V- q: ~, t3 r2 U
Note5 Q$ v# K% |& c- p( J1 E* y, @, c
Please do not specify --subnet option in this case.3 h: t4 p( ?2 {$ j/ ?
The Networking openstackclient requires a router (Name or ID) and name.. P% X0 @" o5 t
Create local endpoint group:  K9 |  ^7 n3 W# M% ?/ e3 {
$ openstack vpn endpoint group create ep_subnet \
. g! y  ~* E+ Q+ t" \  --type subnet \
0 [7 j/ L7 A7 D& Z7 N  --value 1f888dd0-2066-42a1-83d7-56518895e47d
3 G9 z: {3 [7 H  +-------------+-------------------------------------------+
' |6 Q4 w2 r8 q$ m3 x. v, F( k3 ?+ ?  | Field       | Value                                     |& L9 A) K" K# U
  +-------------+-------------------------------------------+
4 J( h. G& H: ?* C, s* v  | Description |                                           |3 D4 E5 I8 A: g5 I! C
  | Endpoints   | [u'1f888dd0-2066-42a1-83d7-56518895e47d'] |
5 o0 U3 o* m6 I* L. a  | ID          | 667296d0-67ca-4d0f-b676-7650cf96e7b1      |
! K" g6 X1 y) f) l  | Name        | ep_subnet                                 |) m. J* H" a& p. }7 l' B
  | Project     | 095247cb2e22455b9850c6efff407584          |! J2 n" T+ D3 b0 r8 c, a
  | Type        | subnet                                    |
# A2 ?4 D1 r# ~) N; S) b! b4 M  | project_id  | 095247cb2e22455b9850c6efff407584          |" Y& s. n* a  y+ S0 J
  +-------------+-------------------------------------------+- {, R8 j# E- [3 m2 p4 X
Note( n. H+ n2 q' `- M' w  ^# g0 n! `' k
The type of a local endpoint group must be subnet.
7 z( V3 N' U/ @3 nCreate peer endpoint group:
: B) x! m! }' o& U6 z1 T0 v$ openstack vpn endpoint group create ep_cidr \" Q4 e6 l0 R/ z' ]" e7 W4 l
  --type cidr \
* H2 F0 X! P' ]1 o2 \& ^) a# W* i  --value 192.168.1.0/24
1 G' P2 ~1 I$ H  j  +-------------+--------------------------------------+
2 F/ u) q5 p2 a3 \& T: M4 `  | Field       | Value                                |9 |- _' t& s4 A  B
  +-------------+--------------------------------------+
- X: O, \3 M# e' E+ I  | Description |                                      |
; N/ F/ H' h+ F  | Endpoints   | [u'192.168.1.0/24']                  |/ n" l( ~3 {+ Y( Z, L+ l5 D( S
  | ID          | 5c3d7f2a-4a2a-446b-9fcf-9a2557cfc641 |7 B9 \0 o* F' _4 v& ^8 G
  | Name        | ep_cidr                              |- _8 I5 `0 q0 J! {8 R
  | Project     | 095247cb2e22455b9850c6efff407584     |( D0 w0 P0 S0 @# j
  | Type        | cidr                                 |! K; z( N8 {) l3 |* B: q; o
  | project_id  | 095247cb2e22455b9850c6efff407584     |& f8 [/ ~/ ]# T/ U- C% C1 A
  +-------------+--------------------------------------+
+ ~& t4 V" v5 i" Q2 E( Z Note
" F% B/ r5 {* d+ C$ OThe type of a peer endpoint group must be cidr.
. c8 I& G9 ?! {Create an ipsec site connection:9 D, \: X+ e4 P+ [$ `$ P2 n
$ openstack vpn ipsec site connection create conn \, V6 f2 r7 v2 o
  --vpnservice vpn \
3 s( Y! R: X# u7 p$ S$ S  --ikepolicy ikepolicy \. m* q9 e, |% }+ Q6 d1 E
  --ipsecpolicy ipsecpolicy \
* v4 Z& O& g) {5 B6 g' ?5 j  --peer-address 192.168.20.9 \
; A" d0 g/ x. x! H6 O8 u  --peer-id 192.168.20.9 \
/ Z# F- [8 @8 k+ G0 t$ m& m7 W  --psk secret \
2 |2 u8 w. b# R  --local-endpoint-group ep_subnet \0 Y& y2 Y9 w( w8 _  E3 D
  --peer-endpoint-group ep_cidr: i# k7 ~- ~/ y* `1 t0 H
  +--------------------------+--------------------------------------------------------+
8 V8 v( Z' O0 S" S. W. J0 O  | Field                    | Value                                                  |. E6 I% t! f9 q  }
  +--------------------------+--------------------------------------------------------+( J* o/ v$ T* _: I2 \- A0 D, A: d
  | Authentication Algorithm | psk                                                    |
7 l8 p3 @  m* J# O- m' p% L  | Description              |                                                        |# u5 z7 V: ~' q1 p2 O' V2 f$ q
  | ID                       | 07e400b7-9de3-4ea3-a9d0-90a185e5b00d                   |
! e! E: Z0 J/ X! J6 E- A/ G# O  | IKE Policy               | 735f4691-3670-43b2-b389-f4d81a60ed56                   |1 X! b  x0 h4 }" F
  | IPSec Policy             | 4f3f46fc-f2dc-4811-a642-9601ebae310f                   |; A0 D3 q% N0 d+ ?& p- V1 u
  | Initiator                | bi-directional                                         |, j$ F* h: R; f' m% P$ P6 t$ n
  | Local Endpoint Group ID  | 667296d0-67ca-4d0f-b676-7650cf96e7b1                   |
0 j  @6 W8 J' R- N4 f  | Local ID                 |                                                        |- A: K* {2 a6 X7 \/ e* Z
  | MTU                      | 1500                                                   |9 O* j3 X0 a! R) _  k, V
  | Name                     | conn                                                   |2 l! ^0 w7 N9 ?3 Q6 i; B2 l, J, Z8 L
  | Peer Address             | 192.168.20.9                                           |
! V) e9 d6 B! |# x  | Peer CIDRs               |                                                        |  ~* u9 G+ Y; `4 Q
  | Peer Endpoint Group ID   | 5c3d7f2a-4a2a-446b-9fcf-9a2557cfc641                   |6 r/ [: h. E' f' x7 s4 K
  | Peer ID                  | 192.168.20.9                                           |. W5 S1 u# ^- `% v4 l7 M9 s7 N
  | Pre-shared Key           | secret                                                 |) I( }  [2 ^0 l6 K3 S7 q0 G
  | Project                  | 095247cb2e22455b9850c6efff407584                       |
( {2 x" |! V$ L% ]  | Route Mode               | static                                                 |
% K7 n9 |5 t: y% M/ X. T. S1 f  | State                    | True                                                   |9 ~% O# I# Q6 E3 g
  | Status                   | PENDING_CREATE                                         |$ S' ~6 B4 b2 x' X
  | VPN Service              | 9f499f9f-f672-4ceb-be3c-d5ff3858c680                   |# r/ v  R; n1 L( O
  | dpd                      | {u'action': u'hold', u'interval': 30, u'timeout': 120} |: I7 b. C9 m; L1 k5 ~
  | project_id               | 095247cb2e22455b9850c6efff407584                       |  u; ?' z: \* J( e' `3 T" n
  +--------------------------+--------------------------------------------------------+9 L. A+ e! C! S1 a
Note3 |- R5 i  R# ^; v/ `: ^
Please do not specify --peer-cidr option in this case. Peer CIDR(s) are provided by a peer endpoint group.: ?+ |0 `  J$ C# O# q
Configure VPNaaS without endpoint group (the legacy way)¶
4 g8 f% K4 @. d# TCreate the IKE policy, IPsec policy, VPN service. Then, create an ipsec site connection that applies the above policies and service.
, B" ]& Z* t0 a0 ~: gCreate an IKE policy:3 T, s6 d  G8 C% O4 U
$ openstack vpn ike policy create ikepolicy1/ T2 D  L6 J: U$ n5 M* c$ X3 z
  +-------------------------------+----------------------------------------+
0 Y, R4 f( ?" `% Q3 e  | Field                         | Value                                  |9 J8 n3 q# R; l: u
  +-------------------------------+----------------------------------------+; f9 A' e& D5 a' m+ M- f* m
  | Authentication Algorithm      | sha1                                   |
$ k8 F- ~' y7 ~+ ?6 X  | Description                   |                                        |
5 E1 l  o2 U5 u1 r: V* C0 K& l$ L  | Encryption Algorithm          | aes-128                                |
; X- p6 z; o1 z  | ID                            | 99e4345d-8674-4d73-acb4-0e2524425e34   |
( z. N+ F; D, w7 {1 H" A  | IKE Version                   | v1                                     |
  J: G  p0 V/ j9 y  | Lifetime                      | {u'units': u'seconds', u'value': 3600} |4 e' S  I) y0 J5 o8 W/ Z
  | Name                          | ikepolicy1                             |
! x8 Z2 L9 h0 P  | Perfect Forward Secrecy (PFS) | group5                                 |( @4 U% Y6 C& h! z; L
  | Phase1 Negotiation Mode       | main                                   |
8 D+ w3 [: j2 E$ j; Z* |$ n' ?  | Project                       | 095247cb2e22455b9850c6efff407584       |
* `# V6 s2 o: o. {1 R8 Y  | project_id                    | 095247cb2e22455b9850c6efff407584       |$ t" `3 V$ @7 @0 [- N" c7 L
  +-------------------------------+----------------------------------------+
8 E" ~7 w" o- m" R6 M' |Create an IPsec policy:
- Q& |6 G5 n9 g  G5 j) W$ openstack vpn ipsec policy create ipsecpolicy1
% {' Z% ]( U4 h1 v5 n7 |% ?; z  +-------------------------------+----------------------------------------+
! V6 L0 `5 C2 U7 l' ?8 z  | Field                         | Value                                  |
# {( X7 C( j9 q; Z3 }  +-------------------------------+----------------------------------------+
# P, |. A/ c) p  M/ {  | Authentication Algorithm      | sha1                                   |2 z5 I- D$ F3 O8 J
  | Description                   |                                        |: E8 H- T# ^/ q* t
  | Encapsulation Mode            | tunnel                                 |
; K* P* J* d  {) W- Y9 _  | Encryption Algorithm          | aes-128                                |
8 V8 j- R( M# E) ^& A  | ID                            | e6f547af-4a1d-4c28-b40b-b97cce746459   |7 J# d' _) {+ a: }
  | Lifetime                      | {u'units': u'seconds', u'value': 3600} |
' ~9 S& J5 c! E9 l. `. G- T) l8 H  | Name                          | ipsecpolicy1                           |
7 e" ?, b; e& o+ m* }  | Perfect Forward Secrecy (PFS) | group5                                 |1 w+ l( ^/ m& Q7 q/ B
  | Project                       | 095247cb2e22455b9850c6efff407584       |
% p" q. C0 N2 s+ L5 [! q: ^1 o  | Transform Protocol            | esp                                    |2 b4 y! \' ~- u
  | project_id                    | 095247cb2e22455b9850c6efff407584       |! [  ?3 P0 Q$ B- b3 m% E0 _
  +-------------------------------+----------------------------------------+! ~% }) R" X. d- T2 o: h! r% ~
Create a VPN service:) W  J# D0 k& W$ p9 T3 \
$ openstack vpn service create vpn \
, b. N3 P- s: Z1 F" }! H  --router 66ca673a-cbbd-48b7-9fb6-bfa7ee3ef724 \
3 \4 k4 S% e! ]- M/ V  --subnet cdfb411e-e818-466a-837c-7f96fc41a6d91 w, F9 D8 x* c2 m8 c+ L* L3 _2 ?
  +----------------+--------------------------------------+" U; ]+ D5 p1 G. X) J
  | Field          | Value                                |
& `+ y! o  T9 w- M/ p6 F& c6 F* f  +----------------+--------------------------------------+
. x5 w$ S. |( J7 r1 e  | Description    |                                      |
9 n1 [3 y% z8 f, v1 M% T  | Flavor         | None                                 |- h, v2 g/ M7 T7 r  w- ~3 V9 o
  | ID             | 79ef6250-ddc3-428f-88c2-0ec8084f4e9a |
7 }( M# H, k( ~  | Name           | vpn                                  |
) z3 \% G- r# O  D. F( V2 w5 i  | Project        | 095247cb2e22455b9850c6efff407584     |
, J: Y; P. \) U8 G  | Router         | 66ca673a-cbbd-48b7-9fb6-bfa7ee3ef724 |" W+ @0 l  V& B
  | State          | True                                 |
4 e7 ^/ I; q0 Z  | Status         | PENDING_CREATE                       |: d9 @4 I  [: j, G& {" t! l
  | Subnet         | cdfb411e-e818-466a-837c-7f96fc41a6d9 |% t+ q2 \7 Z; d; R* f, J: m- ?
  | external_v4_ip | 192.168.20.2                         |
5 G# a+ }7 h; w, X3 ~3 e  i  | external_v6_ip | 2001:db8::d                          |
1 x) a- z2 K# s9 k  | project_id     | 095247cb2e22455b9850c6efff407584     |- n& I+ A; p0 @" b0 |
  +----------------+--------------------------------------+
2 ~4 O9 \8 @' K. |" f Note. B/ T' k! x* G: ?. f$ B
The --subnet option is required in this scenario.1 w- p4 [" j9 A/ o- y
Create an ipsec site connection:
$ r* h3 ~, l: C' L/ n$ openstack vpn ipsec site connection create conn \
" ]% K+ M: o% {8 Z; J  --vpnservice vpn \
& @6 D4 \/ u- I  --ikepolicy ikepolicy1 \" a6 }' j7 m* y+ s
  --ipsecpolicy ipsecpolicy1 \0 |" W! p7 L) k0 J6 m" h+ x
  --peer-address 192.168.20.11 \) V9 i( _9 G8 V) _# G* B1 B
  --peer-id 192.168.20.11 \
, \. c. b: z  d  a  --peer-cidr 192.168.1.0/24 \" P7 i, A% |6 G$ u# e  H
  --psk secret/ l0 W6 r* o" X% v7 j3 h
  +--------------------------+--------------------------------------------------------+  ~; `6 I- C, h- g5 d2 c
  | Field                    | Value                                                  |
) h/ r! X% M/ e) l, O* e5 o1 O/ Q  +--------------------------+--------------------------------------------------------+( o) s; c) @# u( ]! E
  | Authentication Algorithm | psk                                                    |& B- `( T7 x  D" `, L* d6 ]
  | Description              |                                                        |
7 z. ^$ {, c6 ?4 }$ j  S& t  | ID                       | 5b2935e6-b2f0-423a-8156-07ed48703d13                   |  V! _2 N6 W. P) J
  | IKE Policy               | 99e4345d-8674-4d73-acb4-0e2524425e34                   |) V( q7 M$ B4 t2 \) b
  | IPSec Policy             | e6f547af-4a1d-4c28-b40b-b97cce746459                   |
' O; y: y8 D( k! [/ M1 d  | Initiator                | bi-directional                                         |8 l$ g# B$ |, I. Y% `9 |
  | Local Endpoint Group ID  | None                                                   |6 G. l- I9 r! p2 t6 ^; k
  | Local ID                 |                                                        |: T! d0 g0 F) R0 o
  | MTU                      | 1500                                                   |
4 A; ^% W- G) Z& o8 t  | Name                     | conn                                                   |
. L$ v5 W' |* K! t5 I3 _$ n! w) U# B  | Peer Address             | 192.168.20.11                                          |
2 O) A4 |# s$ D) Y. v, q1 b4 C+ D, f0 U  | Peer CIDRs               | 192.168.1.0/24                                         |
( y8 `* g( T7 V/ ?9 H3 d  | Peer Endpoint Group ID   | None                                                   |: J- D* }; Z9 e+ k! T. ?3 _3 _, l
  | Peer ID                  | 192.168.20.11                                          |5 W& x" H, s$ x7 ?4 ?' W
  | Pre-shared Key           | secret                                                 |
5 m+ u& j" P+ {0 S# f  E# N  | Project                  | 095247cb2e22455b9850c6efff407584                       |  v- I) V7 d- K0 W* h2 M
  | Route Mode               | static                                                 |
' X& I7 B" `7 E2 E  | State                    | True                                                   |
3 y9 t7 P& w& p6 X  | Status                   | PENDING_CREATE                                         |
; K7 |4 Q$ V" v" h) N% h  | VPN Service              | 79ef6250-ddc3-428f-88c2-0ec8084f4e9a                   |( t5 R1 a( J2 T4 [' D
  | dpd                      | {u'action': u'hold', u'interval': 30, u'timeout': 120} |
/ g. U3 w8 U% g" R0 k7 k4 R  | project_id               | 095247cb2e22455b9850c6efff407584                       |2 J7 r/ f( B/ ]3 w+ x9 G' }9 O3 S
  +--------------------------+--------------------------------------------------------+
8 Y9 V5 a: R4 @5 ^# a: O Note! k+ j8 V4 Z3 ?. \( b
Please do not specify --local-endpoint-group and --peer-endpoint-group options in this case.
0 r8 v3 {  A: ]. G
& G# c8 \9 c5 G" B* w: E% u

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-26 10:17:48 | 显示全部楼层
Installation
$ Q9 d# p0 N$ ZIn 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).
8 V, N5 s0 ?3 W1 \7 D9 e3 ~0 G
$ H7 g2 y- F4 S+ P4 a! }; \% ^[[local|localrc]]# R; p5 o9 B. a! [% F# @. @/ f, ~- w0 X

( j5 E1 Z, ~, d9 ~& L3 _2 ]3 ]3 jenable_plugin neutron-vpnaas https://git.openstack.org/openstack/neutron-vpnaas2 L8 \( R# r9 c0 N% t' {
# ~4 _8 _; `! E* Q9 a6 A& ]% x6 k) p
disable_service n-net
* s) F! U5 ]7 \+ v5 L3 @enable_service q-svc
$ w" Y# o8 \6 f" @5 kenable_service q-agt/ c  t  e  F9 ?, \" \% }
enable_service q-dhcp; r2 o1 E6 G9 V3 l- M6 s1 @
enable_service q-l3
& D* z+ K% F4 a& N  w8 g% Aenable_service q-meta
7 U: y/ j( N) A8 I3 k2 }# Optional, to enable tempest configuration as part of devstack
+ c8 f# [  M& m0 v' Kenable_service tempest, D/ o' S2 v8 F+ s0 d

  m2 [& }( f! @( ?3 Q( U# IPSec driver to use. Optional, defaults to OpenSwan.+ E: d2 n! n& V) D& A4 }3 E
IPSEC_PACKAGE="openswan"* T. N3 w) |* _5 B
Quick Test Script! n1 x8 U5 f0 l/ I# r1 `6 d' m
http://paste.openstack.org/raw/44702/3 Z! u+ ]! N/ X$ N. r. N3 D: B

( [" Y* Q( a  q' y  \0 T  r* u  AThis quick test script create two site with a router,a network and a subnet connected with public network. Then, connect both site via VPN.
  M& L+ g' T5 r" f! V1 z' I  q; U* e& B$ z& g1 V, \8 r$ B" g
Using Two DevStack Nodes for Testing
, M2 v. u4 k/ d' N' nYou 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)
- w9 [  g+ e# X: m% r+ n1 {4 i; K8 }- N1 o5 z( `/ ]
Example Topology
# o& d6 H0 S! P' i" S/ c" W: H( r7 E$ I( N* E5 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).
% Y3 l% N/ M9 }& \
: ^& g* t" T9 k  g  K      (10.1.0.0/24 - DevStack East)
2 ~& ~2 g0 m; \; l1 @              |
0 o3 ^: \4 k/ u* e! d. i% P              |  10.1.0.1
* ^9 t! Q, V0 |: k     [Neutron Router]% S- N1 `% S7 b' E$ ?0 v
              |  172.24.4.226
' k& ~) `. N" z  H              |) q& s1 u' g8 ^6 M) }
              |  172.24.4.225
0 h. u: Z  Q$ v3 e+ k- {: U     [Internet GW]
' g9 l# [' g& m* G' t( Z9 R, p              |  $ r& W* D4 n" n6 R8 B7 F
              |1 t0 ^$ Y1 }8 w
     [Internet GW]
+ F: H: ~. f" K* H6 |              | 172.24.4.232; N: E7 W, \! p  ?2 j
              |
4 L$ _% k  s1 o6 o1 g$ `              | 172.24.4.233
% R1 u- U; E8 f) V3 a     [Neutron Router]0 K) j* `7 }' [! E7 c
              |  10.2.0.1
  Q/ r% B; }: V              |
- m/ R; U" g8 v+ Y9 }3 n. |0 N! O     (10.2.0.0/24 DevStack West)
, c0 N+ A: H. i$ d$ q6 E! lDevStack Configuration8 q" S! r) J. E7 J4 U  d) Y# w1 L

, _7 _% O' w" A6 h+ g3 |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* i) E/ Q9 T/ ?) }( f* {& p

" x5 m9 z5 p7 h5 g; H6 P; o# pPUBLIC_SUBNET_NAME=yoursubnet
' P  t0 S8 C# F$ I( Q- b8 X9 PPRIVATE_SUBNET_NAME=mysubnet
  z; [4 q9 t" c9 [+ j; kFIXED_RANGE=10.1.0.0/24
9 n  p2 I2 t4 `7 V  k6 ?NETWORK_GATEWAY=10.1.0.1
6 y* l# [. K8 pPUBLIC_NETWORK_GATEWAY=172.24.4.225
. L0 E  X- ?& `) HQ_FLOATING_ALLOCATION_POOL=start=172.24.4.226,end=172.24.4.231
, P. f" V2 }4 B6 R* n) uFor West you can add these lines to localrc to use a different local network, public GW (and implicitly router) IP:
1 j5 v' d' l8 s2 R
( A  d: d+ Y2 {2 f2 f' SPUBLIC_SUBNET_NAME=yoursubnet
" K: O. ~7 w! z) Y* v' {6 `PRIVATE_SUBNET_NAME=mysubnet# z/ e4 g3 S$ A  G
FIXED_RANGE=10.2.0.0/24+ E  O0 G3 O: q6 L  D/ ]
NETWORK_GATEWAY=10.2.0.1, i' |" X! Y& y. @% }/ j
PUBLIC_NETWORK_GATEWAY=172.24.4.232
, Z# O; m. b8 cQ_FLOATING_ALLOCATION_POOL=start=172.24.4.233,end=172.24.4.238% _, W* c* w+ C5 a& w9 J
VPNaaS Configuration. j! s4 O+ H# J

1 ~( B% ?! M1 GWith 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.$ q3 V* E% `5 p* s, h( b( v' i

0 `: ^% G; }( e' w% r1 KOn East
8 W' @8 _2 V0 j3 w9 {0 N
8 f! k6 }1 a) _8 W8 ~0 Cneutron vpn-ikepolicy-create ikepolicy1
) ?5 i* i5 R$ C% Fneutron vpn-ipsecpolicy-create ipsecpolicy1  t6 P& J% y3 h
neutron vpn-service-create --name myvpn --description "My vpn service" router1 mysubnet
# b% b6 e+ o' Z; m  Uneutron 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' m- A: q# w4 ^5 t, u5 p
On West- z+ u/ r9 I0 l- _- {) x/ W4 G

6 x: `2 H0 h. n5 fneutron vpn-ikepolicy-create ikepolicy1
5 Z. L+ h3 u' P( d5 ?+ m1 G2 Vneutron vpn-ipsecpolicy-create ipsecpolicy1
: X5 y) c0 X5 N  d" J) Nneutron vpn-service-create --name myvpn --description "My vpn service" router1 mysubnet
7 Z! B6 [' j) N7 aneutron 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 secret$ D1 Q, J  S! v" E0 D
Note: Please make sure setup security group (open icmp for vpn subnet etc)
6 l" y; G( W8 T% S( j
, G9 I' J- M! C) _" \Verification/ [8 I# s5 j3 w' S

' J5 f% |6 K# J9 L$ C( Z  tYou 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).0 D9 L% f# e" Y$ U
% u! u2 {4 l$ @8 w
Kilo Update
/ U! O7 a. g6 ^" N/ v5 n; v0 [  x/ w- b* p6 l3 C% z3 ^
For 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:$ I2 `- Y$ j  g9 ~6 X) D' Z
$ l3 X9 Z: H- a, f8 \
   OVS_PHYSICAL_BRIDGE=br-ex
4 l1 {8 {2 [+ f  m, i+ P   PUBLIC_INTERFACE=eth1
6 [1 P: [, }0 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.9 j/ N  T  M! [: T9 \

  V  M. O" |6 {. |* hVPNaaS with Single DevStack and Two Routers
2 m/ {4 @: S% s& s5 k6 y& sSimple 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).
, c) w( y( [! |: J7 d
1 g; @, p% C% {# M( AThe 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).
' r* r$ t  _0 P7 r7 j7 G# m
2 }4 y% s- }; v" w9 p& g9 X6 K9 H1 zPreparation) u% ?" R, u* P" r# d
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).
! e& c: m) m* @9 Y; N
/ A$ p; Q! Z) `$ D( Z0 H0 J1 kDevStack Configuration$ u% I/ M& Y) g% ]2 Y9 M6 A& ~: R
For this example, the following local.conf is used:
; t/ y$ C) p" ^8 x$ ?6 d7 Z
5 F* ]- S0 z! X' F/ g9 h/ L   localrc
9 D: |7 G5 T% j8 z$ `% i* i   GIT_BASE=https://github.com
& q# `! k0 W5 U4 E* j( G   DEST=/opt/stack/ C8 `9 `. x8 Q, |) d* g$ w
   8 |* M. N# f" o) @2 Q* t3 S, K9 Q0 c! H
   disable_service n-net# y) x7 R9 ?, _
   enable_service q-svc
. \# }3 _; o; Y   enable_service q-agt
+ p; s, u# H( O   enable_service q-dhcp2 n2 o) Z4 J7 E) u9 I$ `5 J/ a
   enable_service q-l3% @& ~, D! s8 n  J4 O, }7 c
   enable_service q-meta
1 u" Z. t  C) H- Z8 r   enable_service neutron6 t3 n: H7 O7 M" y
   enable_plugin neutron-vpnaas https://git.openstack.org/openstack/neutron-vpnaas
1 W& J- U; L% f  j% ^. }3 k2 l6 H   : I( t3 C0 g" j9 j
   FIXED_RANGE=10.1.0.0/24
: r' H) {! ?; m+ H$ C8 x' T   FIXED_NETWORK_SIZE=256
) s+ a# U- c$ v% U) Z/ x   NETWORK_GATEWAY=10.1.0.19 M" B1 q$ Z  h8 \# ], \+ }
   PRIVATE_SUBNET_NAME=privateA8 R9 V2 [" K# T- A4 I0 _
   : m* N+ H2 }" m/ L/ P, J* b* k- l
   PUBLIC_SUBNET_NAME=public-subnet
% L& f5 N0 ?8 }: \9 f   FLOATING_RANGE=172.24.4.0/244 ~7 S; G$ l5 K" I0 k
   PUBLIC_NETWORK_GATEWAY=172.24.4.10
. {. W* f+ a# V7 m2 q! f4 s   Q_FLOATING_ALLOCATION_POOL="start=172.24.4.11,end=172.24.4.29"
9 W9 K* f  _1 P$ V+ ^   2 A! s6 B: B0 c/ m6 D: l' E
   LIBVIRT_TYPE=qemu/ N2 e$ @5 u' Y# g& s% ]6 d& a" Q
   " Z) X" ]8 Z8 M: i
   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"! q+ I& u4 L5 d/ k) K
   5 a' k2 V) p7 K7 ~
   SCREEN_LOGDIR=/opt/stack/screen-logs- c% _! e  o& {* e5 ^; Y: H% V
   SYSLOG=True- M, g+ h* l: c6 n& G8 z2 h
   LOGFILE=~/devstack/stack.sh.log9 Y! e5 d0 L) n, ]
   ( V9 Q& W  D9 n+ N
   ADMIN_PASSWORD=password
( |9 A) q( s5 I5 w- R- a   MYSQL_PASSWORD=password
9 k. Z" g; [7 r4 X5 F9 s1 ^8 Z   RABBIT_PASSWORD=password
! \" D) T( M- `   SERVICE_PASSWORD=password
4 @' p# T. ]; |$ T   SERVICE_TOKEN=tokentoken2 o* s# N4 q0 Q% C+ l3 n
   6 J, g% V: n4 V: O  K/ p
   Q_USE_DEBUG_COMMAND=True
) N/ ^: K5 A5 I: {2 O2 c* \   ) }$ b! H- T7 Z, y4 V+ N% g- q6 m2 _
   # RECLONE=No
) t  Z6 ?: u& ^   RECLONE=yes
  ^" v) G0 _& Y" K   OFFLINE=False7 Y! U5 ]9 L3 g& S" q  w
Start up the cloud using ./stack.sh and ensure it completes successfully. Once stacked, you can change RECLONE to No.
) n% Z2 I! u. z% V8 i+ |) S% C) ~$ p1 K
Cloud Configuration5 \5 N" O( v5 K* w6 Q0 T8 @
Once 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.7 m0 x8 R* U* C4 |

, B2 a+ _# ^+ P+ B* ?   # Create second net, subnet, router. \% B% X1 \% H8 Y+ U2 x, {
   source ~/devstack/openrc admin demo- r8 k( p8 J7 ^! {( T
   neutron net-create privateB
. X7 C3 L) c; s4 [- M   neutron subnet-create --name subB privateB 10.2.0.0/24 --gateway 10.2.0.1
% N& m3 }9 O: ^0 x1 m8 P3 X6 _   neutron router-create router2
+ G# e  j( t. C0 S" B$ Y3 @# T   neutron router-interface-add router2 subB+ @6 i/ }/ v# Y
   neutron router-gateway-set router2 public
' `& ~" h, e' [' m& g; U   
. `# c7 c+ W! x. w5 j6 z0 u   # Start up a VM in the privateA subnet.
' D, o' W: Z) q9 S: p( ]- X. j   PRIVATE_NET=`neutron net-list | grep 'private ' | cut -f 2 -d' '`) p7 S( m9 a1 T4 V/ V! X! w
   nova boot --flavor 1 --image cirros-0.3.3-x86_64-uec --nic net-id=$PRIVATE_NET peter
; o$ t7 h9 z5 ^   
* q5 |& i+ R6 {6 q: c   # Start up a VM in the privateB subnet9 ?& x) y2 ?1 l$ H( b, i; J5 u
   PRIVATE_NETB=`neutron net-list | grep privateB | cut -f 2 -d' '`
) r; Q; f/ X: \. {* m9 n4 Y   nova boot --flavor 1 --image cirros-0.3.3-x86_64-uec --nic net-id=$PRIVATE_NETB paul% F% {: Q+ N  ~' Q
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.
6 a1 h1 [" d+ a  D2 R) d8 P: I: b6 M: X# E& A) n) w
IPSec Site-to-site Connection Creation
$ N; `% r+ |) {; J5 L5 I) t( D7 pThe following commands will create the IPSec connection:
, k1 k$ k5 _; q- U4 }% [8 M$ F& V0 e' [3 ?% a  |2 K6 I" q
   # Create VPN connections, W. x8 U2 O6 J4 }6 k
   neutron vpn-ikepolicy-create ikepolicy$ p! d0 N5 y8 L# S- X5 {
   neutron vpn-ipsecpolicy-create ipsecpolicy
& h' e8 i- ~  `! G% ]5 s3 j: \   neutron vpn-service-create --name myvpn --description "My vpn service" router1 privateA
, Y2 l  Q, C, m# U$ u   
% d4 ~! f2 ?) ^7 h0 H7 j   neutron ipsec-site-connection-create --name vpnconnection1 --vpnservice-id myvpn \
+ u3 N* f# Q: U; q9 |% O   --ikepolicy-id ikepolicy --ipsecpolicy-id ipsecpolicy --peer-address 172.24.4.13 \1 b+ X( p6 O! W4 l- e
   --peer-id 172.24.4.13 --peer-cidr 10.2.0.0/24 --psk secret
# r1 H) E/ X1 A   
* ?- S  B3 P# U5 \   neutron vpn-service-create --name myvpnB --description "My vpn serviceB" router2 subB
# t6 {; v! ?& x3 Q% q1 p   4 e0 ]4 [# L5 e: S0 a% T. X
   neutron ipsec-site-connection-create --name vpnconnection2 --vpnservice-id myvpnB \
. i  O; k* F, w8 W; R   --ikepolicy-id ikepolicy --ipsecpolicy-id ipsecpolicy --peer-address 172.24.4.11 \
- T" {% |8 ]/ Z8 w  `: y/ B1 m* l   --peer-id 172.24.4.11 --peer-cidr 10.1.0.0/24 --psk secret
; |5 c6 S1 Z0 x6 C) z4 DAt 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 :).
" j- a! T5 P* O. T0 X& y3 G, f% F) m3 `( |
Multiple Local Subnets" O6 D1 y5 m; a0 f( {
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.+ U# d6 y$ R9 P9 Q# z

" t) D5 G- U% n  c) ]0 sTo 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:
2 z& Q! Q% [3 K- D+ S! g* l3 U7 O4 F
   # Create VPN connections
' k: ~9 ^/ c7 ]# J   neutron vpn-ikepolicy-create ikepolicy
. m, Z" o& W7 E$ h   neutron vpn-ipsecpolicy-create ipsecpolicy
, Z7 K1 @9 I+ _; J   neutron vpn-service-create --name myvpnC --description "My vpn service" router1
0 Q0 c, J# q/ y5 M% ]2 PTo 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:% o1 f- {! U4 P  |4 O9 Y
$ M( q1 X$ g5 `" u& P
   neutron vpn-endpoint-group-create --name my-locals --type subnet --value privateA --value privateA2: r0 h3 s4 P- w. ^% C* r- O
   neutron vpn-endpoint-group-create --name my-peers --type cidr --value 10.2.0.0/24 --value 20.2.0.0/24
6 j& v3 M8 t2 w* u" E. Twhere 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:, Q; f1 _1 d9 J
) \2 u/ t/ V. t4 Y
   neutron ipsec-site-connection-create --name vpnconnection3 --vpnservice-id myvpnC \
" k6 r% l7 ]7 e2 r* i" a% ]) T9 a: ?   --ikepolicy-id ikepolicy --ipsecpolicy-id ipsecpolicy --peer-address 172.24.4.11 \, S- S. y+ ?6 U3 T0 h: {' B% p. N
   --peer-id 172.24.4.11 --local-ep-group my-locals --peer-ep-group my-peers --psk secret
7 u. q6 t% e. o+ J3 ?" c9 VNotes:1 I! J0 P" b, w  \, @2 @1 V

5 }4 ?8 d; m, z# y9 @% A1 O5 E- jThe validation logic makes sure that endpoint groups and peer CIDRs are not intermixed.
# R6 z" ^) u' nEndpoint group types are subnet, cidr, network, router, and vlan. However, only subnet and cidr are implemented (for IPSec use).
$ v: U; H7 [  w: P6 l) bThe endpoints in a group must be of the same type, although can mix IP versions.: M4 `/ {' D4 Q
For IPSec connections, validation currently enforces that the local and peer endpoints all use the same IP version./ P0 {4 w4 @4 _  I
IPSec connection validation requires that local endpoints are subnets, and peer endpoints are CIDRs.
: p# _, Z) x: u  H- a4 fMigration will convert information for any existing VPN services and connections to endpoint groups.
1 _/ W) u# b+ k' `6 F  m+ m: [1 TThe original APIs will work for backward compatibility., s6 f; w# W* T
Horizon Support! v% N2 i' f6 t$ ~0 c1 L; |
Checkout Test branch
6 e8 g: s' _7 f3 c/ I" WHorizon support has been merged.2 u7 C0 R" Q7 k+ H

" p5 c% i( S) c, |Enable VPN section in Horizon
8 Z. m6 w) j9 }& L# w  yNote that ff q-vpn is enabled Horizon VPN support is enabled automatically.
3 \; n( i3 B6 {+ S# B" l: k- o& F% J, v; A( W/ d- U$ y
Open: F. z& W7 z- q
/opt/stack/horizon/openstack_dashboard/local/local_settings.py
8 i8 a& D1 ?& B7 W* @6 x( ]and replace9 k" B( c. c% c9 A" ]6 a; }/ K0 T
5 H% j5 ?' k5 S0 G3 V3 _
OPENSTACK_NEUTRON_NETWORK = {" O* r0 m- L3 w+ v3 T
    'enable_vpn': False,
5 @- @" u8 L; N. Y+ A}
: W# t/ }0 u6 Y9 A" |with
! t* a. ^3 i+ a4 K
  T! e" p0 D! B5 W' H& s: rOPENSTACK_NEUTRON_NETWORK = {
) W$ w$ m$ p. n6 Z% }    'enable_vpn': True,, {7 U1 T! [1 T5 L3 J
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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