
 
 h t t p s : / / g i t h u b . c o m / h w d s l 2 / s e t u p - i p s e c - v p n 
 
 
 
 
 
 
 
 S e t   u p   y o u r   o w n   I P s e c   V P N   s e r v e r   i n   j u s t   a   f e w   m i n u t e s ,   w i t h   b o t h   I P s e c / L 2 T P   a n d   C i s c o   I P s e c   o n   U b u n t u ,   D e b i a n   a n d   C e n t O S .   
 
 A l l   y o u   n e e d   t o   d o   i s   p r o v i d e   y o u r   o w n   V P N   c r e d e n t i a l s ,   
 
 a n d   l e t   t h e   s c r i p t s   h a n d l e   t h e   r e s t . 
 
 
 
 A n   I P s e c   V P N   e n c r y p t s   y o u r   n e t w o r k   t r a f f i c ,   
 
 s o   t h a t   n o b o d y   b e t w e e n   y o u   a n d   t h e   V P N   s e r v e r   c a n   e a v e s d r o p   o n   y o u r   d a t a   a s   i t   t r a v e l s   v i a   t h e   I n t e r n e t .   
 
 T h i s   i s   e s p e c i a l l y   u s e f u l   w h e n   u s i n g   u n s e c u r e d   n e t w o r k s ,   e . g .   a t   c o f f e e   s h o p s ,   a i r p o r t s   o r   h o t e l   r o o m s . 
 
 
 
 
 
 W e   w i l l   u s e   L i b r e s w a n   a s   t h e   I P s e c   s e r v e r ,   a n d   x l 2 t p d   a s   t h e   L 2 T P   p r o v i d e r . 
 
 
 
 
 
 
 
 Q u i c k   s t a r t 
 
 F i r s t ,   p r e p a r e   y o u r   L i n u x   s e r v e r *   w i t h   a   f r e s h   i n s t a l l   o f   U b u n t u   L T S ,   D e b i a n   o r   C e n t O S . 
 
 
 
 U s e   t h i s   o n e - l i n e r   t o   s e t   u p   a n   I P s e c   V P N   s e r v e r : 
 
 
 
 w g e t   h t t p s : / / g i t . i o / v p n s e t u p   - O   v p n s e t u p . s h   & &   s u d o   s h   v p n s e t u p . s h 
 
 I f   u s i n g   C e n t O S ,   r e p l a c e   t h e   l i n k   a b o v e   w i t h   h t t p s : / / g i t . i o / v p n s e t u p - c e n t o s . 
 
 
 
 Y o u r   V P N   l o g i n   d e t a i l s   w i l l   b e   r a n d o m l y   g e n e r a t e d ,   a n d   d i s p l a y e d   o n   t h e   s c r e e n   w h e n   f i n i s h e d . 
 
 
 
 F o r   o t h e r   i n s t a l l a t i o n   o p t i o n s   a n d   h o w   t o   s e t   u p   V P N   c l i e n t s ,   r e a d   t h e   s e c t i o n s   b e l o w . 
 
 
 
 *   A   d e d i c a t e d   s e r v e r   o r   v i r t u a l   p r i v a t e   s e r v e r   ( V P S ) .   O p e n V Z   V P S   i s   n o t   s u p p o r t e d . 
 
 
 
 F e a t u r e s 
 
 N e w :   T h e   f a s t e r   I P s e c / X A u t h   ( " C i s c o   I P s e c " )   m o d e   i s   s u p p o r t e d 
 
 N e w :   A   p r e - b u i l t   D o c k e r   i m a g e   o f   t h e   V P N   s e r v e r   i s   n o w   a v a i l a b l e 
 
 F u l l y   a u t o m a t e d   I P s e c   V P N   s e r v e r   s e t u p ,   n o   u s e r   i n p u t   n e e d e d 
 
 E n c a p s u l a t e s   a l l   V P N   t r a f f i c   i n   U D P   -   d o e s   n o t   n e e d   E S P   p r o t o c o l 
 
 C a n   b e   d i r e c t l y   u s e d   a s   " u s e r - d a t a "   f o r   a   n e w   A m a z o n   E C 2   i n s t a n c e 
 
 I n c l u d e s   s y s c t l . c o n f   o p t i m i z a t i o n s   f o r   i m p r o v e d   p e r f o r m a n c e 
 
 T e s t e d   w i t h   U b u n t u   1 8 . 0 4 / 1 6 . 0 4 ,   D e b i a n   1 0 / 9 / 8   a n d   C e n t O S   8 / 7 / 6 
 
 R e q u i r e m e n t s 
 
 A   n e w l y   c r e a t e d   A m a z o n   E C 2   i n s t a n c e ,   f r o m   o n e   o f   t h e s e   i m a g e s : 
 
 
 
 U b u n t u   1 8 . 0 4   ( B i o n i c )   o r   1 6 . 0 4   ( X e n i a l ) 
 
 D e b i a n   1 0   ( B u s t e r ) * ,   9   ( S t r e t c h )   o r   8   ( J e s s i e ) 
 
 C e n t O S   8   ( x 8 6 _ 6 4 )   w i t h   U p d a t e s   * * 
 
 C e n t O S   7   ( x 8 6 _ 6 4 )   w i t h   U p d a t e s 
 
 C e n t O S   6   ( x 8 6 _ 6 4 )   w i t h   U p d a t e s 
 
 R e d   H a t   E n t e r p r i s e   L i n u x   ( R H E L )   8 ,   7   o r   6 
 
 P l e a s e   s e e   d e t a i l e d   i n s t r u c t i o n s   a n d   E C 2   p r i c i n g . 
 
 
 
 - O R - 
 
 
 
 A   d e d i c a t e d   s e r v e r   o r   K V M / X e n - b a s e d   v i r t u a l   p r i v a t e   s e r v e r   ( V P S ) ,   
 
 f r e s h l y   i n s t a l l e d   w i t h   o n e   o f   t h e   a b o v e   O S .   O p e n V Z   V P S   i s   n o t   s u p p o r t e d ,   
 
 u s e r s   c o u l d   i n s t e a d   t r y   O p e n V P N . 
 
 
 
 T h i s   a l s o   i n c l u d e s   L i n u x   V M s   i n   p u b l i c   c l o u d s ,   s u c h   a s   D i g i t a l O c e a n ,   
 
 V u l t r ,   L i n o d e ,   G o o g l e   C o m p u t e   E n g i n e ,   A m a z o n   L i g h t s a i l ,   M i c r o s o f t   A z u r e ,   
 
 I B M   C l o u d ,   O V H   a n d   R a c k s p a c e . 
 
 
 
 D e p l o y   t o   A z u r e   I n s t a l l   o n   D i g i t a l O c e a n   D e p l o y   t o   L i n o d e 
 
 
 
    I   w a n t   t o   r u n   m y   o w n   V P N   b u t   d o n ' t   h a v e   a   s e r v e r   f o r   t h a t 
 
 
 
 A d v a n c e d   u s e r s   c a n   s e t   u p   t h e   V P N   s e r v e r   o n   a   $ 3 5   R a s p b e r r y   P i .   S e e   [ 1 ]   [ 2 ] . 
 
 
 
 *   D e b i a n   1 0   u s e r s   s h o u l d   u s e   t h e   s t a n d a r d   L i n u x   k e r n e l   ( n o t   t h e   " c l o u d "   v e r s i o n ) .   R e a d   m o r e   h e r e . 
 
 * *   C e n t O S   8   d o e s   n o t   y e t   h a v e   a n   o f f i c i a l   E C 2   i m a g e . 
 
 
 
 w a r n i n g   D O   N O T   r u n   t h e s e   s c r i p t s   o n   y o u r   P C   o r   M a c !   T h e y   s h o u l d   o n l y   b e   u s e d   o n   a   s e r v e r ! 
 
 
 
 I n s t a l l a t i o n 
 
 U b u n t u   &   D e b i a n 
 
 F i r s t ,   u p d a t e   y o u r   s y s t e m   w i t h   a p t - g e t   u p d a t e   & &   a p t - g e t   d i s t - u p g r a d e   a n d   r e b o o t .   T h i s   i s   o p t i o n a l ,   b u t   r e c o m m e n d e d . 
 
 
 
 T o   i n s t a l l   t h e   V P N ,   p l e a s e   c h o o s e   o n e   o f   t h e   f o l l o w i n g   o p t i o n s : 
 
 
 
 O p t i o n   1 :   H a v e   t h e   s c r i p t   g e n e r a t e   r a n d o m   V P N   c r e d e n t i a l s   f o r   y o u   ( w i l l   b e   d i s p l a y e d   w h e n   f i n i s h e d ) : 
 
 
 
 w g e t   h t t p s : / / g i t . i o / v p n s e t u p   - O   v p n s e t u p . s h   & &   s u d o   s h   v p n s e t u p . s h 
 
 O p t i o n   2 :   E d i t   t h e   s c r i p t   a n d   p r o v i d e   y o u r   o w n   V P N   c r e d e n t i a l s : 
 
 
 
 w g e t   h t t p s : / / g i t . i o / v p n s e t u p   - O   v p n s e t u p . s h 
 
 n a n o   - w   v p n s e t u p . s h 
 
 [ R e p l a c e   w i t h   y o u r   o w n   v a l u e s :   Y O U R _ I P S E C _ P S K ,   Y O U R _ U S E R N A M E   a n d   Y O U R _ P A S S W O R D ] 
 
 s u d o   s h   v p n s e t u p . s h 
 
 N o t e :   A   s e c u r e   I P s e c   P S K   s h o u l d   c o n s i s t   o f   a t   l e a s t   2 0   r a n d o m   c h a r a c t e r s . 
 
 
 
 O p t i o n   3 :   D e f i n e   y o u r   V P N   c r e d e n t i a l s   a s   e n v i r o n m e n t   v a r i a b l e s : 
 
 
 
 #   A l l   v a l u e s   M U S T   b e   p l a c e d   i n s i d e   ' s i n g l e   q u o t e s ' 
 
 #   D O   N O T   u s e   t h e s e   s p e c i a l   c h a r a c t e r s   w i t h i n   v a l u e s :   \   "   ' 
 
 w g e t   h t t p s : / / g i t . i o / v p n s e t u p   - O   v p n s e t u p . s h   & &   s u d o   \ 
 
 V P N _ I P S E C _ P S K = ' y o u r _ i p s e c _ p r e _ s h a r e d _ k e y '   \ 
 
 V P N _ U S E R = ' y o u r _ v p n _ u s e r n a m e '   \ 
 
 V P N _ P A S S W O R D = ' y o u r _ v p n _ p a s s w o r d '   \ 
 
 s h   v p n s e t u p . s h 
 
 N o t e :   I f   u n a b l e   t o   d o w n l o a d   v i a   w g e t ,   y o u   m a y   a l s o   o p e n   v p n s e t u p . s h   ( o r   v p n s e t u p _ c e n t o s . s h )   a n d   c l i c k   t h e   R a w   b u t t o n .   
 
 P r e s s   C t r l - A   t o   s e l e c t   a l l ,   C t r l - C   t o   c o p y ,   t h e n   p a s t e   i n t o   y o u r   f a v o r i t e   e d i t o r . 
 
 
 
 C e n t O S   &   R H E L 
 
 F i r s t ,   u p d a t e   y o u r   s y s t e m   w i t h   y u m   u p d a t e   a n d   r e b o o t .   T h i s   i s   o p t i o n a l ,   b u t   r e c o m m e n d e d . 
 
 
 
 F o l l o w   t h e   s a m e   s t e p s   a s   a b o v e ,   b u t   r e p l a c e   h t t p s : / / g i t . i o / v p n s e t u p   w i t h   h t t p s : / / g i t . i o / v p n s e t u p - c e n t o s . 
 
 
 
 N e x t   s t e p s 
 
 G e t   y o u r   c o m p u t e r   o r   d e v i c e   t o   u s e   t h e   V P N .   P l e a s e   r e f e r   t o : 
 
 
 
 C o n f i g u r e   I P s e c / L 2 T P   V P N   C l i e n t s 
 
 
 
 C o n f i g u r e   I P s e c / X A u t h   ( " C i s c o   I P s e c " )   V P N   C l i e n t s 
 
 
 
 S t e p - b y - S t e p   G u i d e :   H o w   t o   S e t   U p   I K E v 2   V P N 
 
 
 
 I f   y o u   g e t   a n   e r r o r   w h e n   t r y i n g   t o   c o n n e c t ,   s e e   T r o u b l e s h o o t i n g . 
 
 
 
 E n j o y   y o u r   v e r y   o w n   V P N !   s p a r k l e s t a d a r o c k e t s p a r k l e s 
 
 
 
 I m p o r t a n t   n o t e s 
 
 R e a d   t h i s   i n   o t h e r   l a n g u a g e s :   E n g l i s h ,   {SO-Ne. 
 
 
 
 W i n d o w s   u s e r s :   T h i s   o n e - t i m e   r e g i s t r y   c h a n g e   i s   r e q u i r e d   i f   t h e   V P N   s e r v e r   a n d / o r   c l i e n t   i s   b e h i n d   N A T   ( e . g .   h o m e   r o u t e r ) . 
 
 
 
 A n d r o i d   6   a n d   7   u s e r s :   I f   y o u   e n c o u n t e r   c o n n e c t i o n   i s s u e s ,   t r y   t h e s e   s t e p s . 
 
 
 
 T h e   s a m e   V P N   a c c o u n t   c a n   b e   u s e d   b y   y o u r   m u l t i p l e   d e v i c e s .   H o w e v e r ,   d u e   t o   a n   I P s e c / L 2 T P   l i m i t a t i o n ,   
 
 i f   y o u   w i s h   t o   c o n n e c t   m u l t i p l e   d e v i c e s   s i m u l t a n e o u s l y   f r o m   b e h i n d   t h e   s a m e   N A T   ( e . g .   h o m e   r o u t e r ) ,   y o u   m u s t   u s e   o n l y   I P s e c / X A u t h   m o d e . 
 
 
 
 F o r   s e r v e r s   w i t h   a n   e x t e r n a l   f i r e w a l l   ( e . g .   E C 2 / G C E ) ,   o p e n   U D P   p o r t s   5 0 0   a n d   4 5 0 0   f o r   t h e   V P N .   A l i y u n   u s e r s ,   s e e   # 4 3 3 . 
 
 
 
 I f   y o u   w i s h   t o   a d d ,   e d i t   o r   r e m o v e   V P N   u s e r   a c c o u n t s ,   s e e   M a n a g e   V P N   U s e r s .   H e l p e r   s c r i p t s   a r e   i n c l u d e d   f o r   c o n v e n i e n c e . 
 
 
 
 
 
 C l i e n t s   a r e   s e t   t o   u s e   G o o g l e   P u b l i c   D N S   w h e n   t h e   V P N   i s   a c t i v e .   
 
 I f   a n o t h e r   D N S   p r o v i d e r   i s   p r e f e r r e d ,   r e p l a c e   8 . 8 . 8 . 8   a n d   8 . 8 . 4 . 4   i n   b o t h   / e t c / p p p / o p t i o n s . 
 
 x l 2 t p d   a n d   / e t c / i p s e c . c o n f ,   t h e n   r e b o o t   y o u r   s e r v e r .   
 
 A d v a n c e d   u s e r s   c a n   d e f i n e   V P N _ D N S _ S R V 1   a n d   o p t i o n a l l y   V P N _ D N S _ S R V 2   w h e n   r u n n i n g   t h e   V P N   s e t u p   s c r i p t . 
 
 
 
 
 
 U s i n g   k e r n e l   s u p p o r t   c o u l d   i m p r o v e   I P s e c / L 2 T P   p e r f o r m a n c e .   I t   i s   a v a i l a b l e   o n   U b u n t u   1 8 . 0 4 / 1 6 . 0 4 ,   
 
 D e b i a n   1 0 / 9   a n d   C e n t O S   8 / 7 / 6 .   U b u n t u   u s e r s :   I n s t a l l   l i n u x - m o d u l e s - e x t r a - $ ( u n a m e   - r )   ( o r   l i n u x - i m a g e - e x t r a ) ,   
 
 t h e n   r u n   s e r v i c e   x l 2 t p d   r e s t a r t . 
 
 
 
 T o   m o d i f y   t h e   I P T a b l e s   r u l e s   a f t e r   i n s t a l l ,   e d i t   / e t c / i p t a b l e s . r u l e s   a n d / o r   / e t c / i p t a b l e s / r u l e s . v 4   ( U b u n t u / D e b i a n ) ,   
 
 o r   / e t c / s y s c o n f i g / i p t a b l e s   ( C e n t O S / R H E L ) .   T h e n   r e b o o t   y o u r   s e r v e r . 
 
 
 
 W h e n   c o n n e c t i n g   v i a   I P s e c / L 2 T P ,   t h e   V P N   s e r v e r   h a s   I P   1 9 2 . 1 6 8 . 4 2 . 1   w i t h i n   t h e   V P N   s u b n e t   1 9 2 . 1 6 8 . 4 2 . 0 / 2 4 . 
 
 
 
 T h e   s c r i p t s   w i l l   b a c k u p   e x i s t i n g   c o n f i g   f i l e s   b e f o r e   m a k i n g   c h a n g e s ,   w i t h   . o l d - d a t e - t i m e   s u f f i x . 
 
 
 
 U p g r a d e   L i b r e s w a n 
 
 T h e   a d d i t i o n a l   s c r i p t s   v p n u p g r a d e . s h   a n d   v p n u p g r a d e _ c e n t o s . s h   c a n   b e   u s e d   t o   u p g r a d e   L i b r e s w a n   ( c h a n g e l o g   |   a n n o u n c e ) .   
 
 E d i t   t h e   S W A N _ V E R   v a r i a b l e   a s   n e c e s s a r y .   C h e c k   w h i c h   v e r s i o n   i s   i n s t a l l e d :   i p s e c   - - v e r s i o n . 
 
 
 
 #   U b u n t u   &   D e b i a n 
 
 w g e t   h t t p s : / / g i t . i o / v p n u p g r a d e   - O   v p n u p g r a d e . s h 
 
 #   C e n t O S   &   R H E L 
 
 w g e t   h t t p s : / / g i t . i o / v p n u p g r a d e - c e n t o s   - O   v p n u p g r a d e . s h 
 
 B u g s   &   Q u e s t i o n s 
 
 G o t   a   q u e s t i o n ?   P l e a s e   f i r s t   s e a r c h   o t h e r   p e o p l e ' s   c o m m e n t s   i n   t h i s   G i s t   a n d   o n   m y   b l o g . 
 
 A s k   V P N   r e l a t e d   q u e s t i o n s   o n   t h e   L i b r e s w a n   o r   s t r o n g S w a n   m a i l i n g   l i s t ,   o r   r e a d   t h e s e   w i k i s :   [ 1 ]   [ 2 ]   [ 3 ]   [ 4 ]   [ 5 ] . 
 
 I f   y o u   f o u n d   a   r e p r o d u c i b l e   b u g ,   o p e n   a   G i t H u b   I s s u e   t o   s u b m i t   a   b u g   r e p o r t . 
 
 U n i n s t a l l a t i o n 
 
 P l e a s e   r e f e r   t o   U n i n s t a l l   t h e   V P N . 
 
 
 
 S e e   a l s o 
 
 I P s e c   V P N   S e r v e r   o n   D o c k e r 
 
 A l g o   V P N 
 
 S t r e i s a n d 
 
 O p e n V P N   I n s t a l l 
 
 L i c e n s e 
 
 C o p y r i g h t   ( C )   2 0 1 4 - 2 0 1 9   L i n   S o n g   V i e w   m y   p r o f i l e   o n   L i n k e d I n 
 
 B a s e d   o n   t h e   w o r k   o f   T h o m a s   S a r l a n d i e   ( C o p y r i g h t   2 0 1 2 ) 
 
 
 
 T h i s   w o r k   i s   l i c e n s e d   u n d e r   t h e   C r e a t i v e   C o m m o n s   A t t r i b u t i o n - S h a r e A l i k e   3 . 0   U n p o r t e d   L i c e n s e 
 
 A t t r i b u t i o n   r e q u i r e d :   p l e a s e   i n c l u d e   m y   n a m e   i n   a n y   d e r i v a t i v e   a n d   l e t   m e   k n o w   h o w   y o u   h a v e   i m p r o v e d   i t ! 
 
 
 
 
 
 
 
 
 
 
 
 