Alibaba Cloud Ubuntu 16.04 builds IPSec service

Alibaba Cloud Ubuntu 16.04 builds IPSec service

Introduction to IPSec

IPSec (Internet Protocol Security): is a set of secure communication protocols based on the network layer and applied cryptography. IPSec does not refer to any specific protocol, but is an open protocol family.

The design goal of the IPSec protocol is to provide flexible security services for network layer traffic in IPV4 and IPV6 environments.

IPSec VPN: A secure virtual private network implemented at the IP layer based on the IPSec protocol suite. The security of OSI upper layer protocol data is ensured by inserting a predefined header into the data packet. It is mainly used to protect TCP, UDP, ICMP and tunneled IP data packets.

Due to some restrictions on Alibaba Cloud, deploying IPSec on Alibaba Cloud ECS is different from deploying it on ordinary servers.

Install strongswan

apt-get update
apt-get install strongswan strongswan-plugin-xauth-generic

Edit /etc/ipsec.secrets

vi /etc/ipsec.secrets

Increase:

:PSK "test"
user1 : XAUTH "user1password"

PSK is the pre-shared key, which is a Unicode string used to authenticate the L2TP/IPSec connection. user1 is the user name and user1password is the password.

Edit /etc/ipsec.conf

config setup
 cachecrls=yes
 uniqueids=yes

conn ios
 keyexchange=ikev1
 authby=xauthpsk
 xauth=server
 left=%defaultroute
 leftsubnet=0.0.0.0/0
 leftfirewall=yes
 right=%any
 rightsubnet=192.168.0.1/16
 rightsourceip=192.168.0.1/16
 rightdns=223.5.5.5
 auto=add

Note that you should use the 192.168 network segment instead of the 10.0.0.1 network segment. The 10.0.0.1 network segment seems to have problems on Alibaba Cloud (it is said to be banned?).

Restart strongswan

ipsec restart

Modify the security group rules corresponding to the Alibaba Cloud server

Add two public network access ports: UDP 500 and UDP 4500

Enable IPv4 forwarding and set NAT rules

sysctl net.ipv4.ip_forward=1

iptables -t nat -A POSTROUTING -s 192.168.0.1/16 -o eth1 -j MASQUERADE

Note that eth1 is used, not eth0.

In ECS, eth1 is bound to the external network card, and eth0 is the internal network card.

Related reading:

How to build pptpd service in Alibaba Cloud Ubuntu 16.04

Summarize

The above is the introduction of Alibaba Cloud Ubuntu 16.04 IPSec service. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • How to build pptpd service in Alibaba Cloud Ubuntu 16.04
  • Detailed explanation of how to connect node to mongodb database [Alibaba Cloud Server Environment Ubuntu]
  • Alibaba Cloud Server Ubuntu Configuration Tutorial
  • Alibaba Cloud Deployment of Ubuntu 1.4 Flask + WSGI + Nginx Detailed Explanation
  • How to change the Alibaba Cloud source in Ubuntu 14.04
  • Graphic tutorial on configuring and accessing Alibaba Cloud Server (Ubuntu system) on Mac
  • Analyze the configuration of Apache+PHP+PHPmyadmin+MYsql in Alibaba Cloud Ubuntu 12.04 environment

<<:  MySQL users and permissions and examples of how to crack the root password

>>:  Complete example of vue polling request solution

Recommend

Analysis of multi-threaded programming examples under Linux

1 Introduction Thread technology was proposed as ...

Vue folding display multi-line text component implementation code

Folding display multi-line text component Fold an...

Detailed explanation of identifying files with the same content on Linux

Preface Sometimes file copies amount to a huge wa...

How to solve the margin collapse problem in CSS

First, let's look at three situations where m...

Exploration of three underlying mechanisms of React global state management

Table of contents Preface props context state Sum...

VMware Workstation 14 Pro installs CentOS 7.0

The specific method of installing CentOS 7.0 on V...

How to install Mysql5.7 in Centos6

environment Centos 6.6 MySQL 5.7 Install If the s...

Implementing a simple web clock with JavaScript

Use JavaScript to implement a web page clock. The...

Installation method of MySQL 5.7.18 decompressed version under Win7x64

Related reading: Solve the problem that the servi...

How to configure environment variables in Linux environment

JDK download address: http://www.oracle.com/techn...