Professional Documents
Culture Documents
• NOTE : Một điểm đáng lưu ý nữa là các subnet đều giống nhau, thông qua việc cấu hình bảng định tuyến và cấp phát địa chỉ IP public mà chúng ta mới chia
thành Public và Private Subnet.
• In the VPC interface
• Select Subnets
• Select Public Subnet 1 & 2
• Select Actions
• Select Edit subnet settings
• Create an Internet Gateway
• In the VPC interface
• Select Internet Gateways
• Select Create internet gateway
• Make a configuration
• Name tag, enter Internet Gateway
• Select Create internet gateway
• Implement Attach VPC
• Select Actions
• Select Attach to VPC
• Select ASG, VPC ID will be automatically filled in.
• Select Attach internet gateway
• Create Route Table to route outbound internet through Internet Gateway.
• In the VPC interface
• Select Route Tables
• Select Create route table
5. Configure Network
- VPC, select ASG
- Subnet, select Public Subnet 1
- Auto-assign public IP, select Enable
- Firewall (Security Group), select Select existing security group
- Select Public subnet -SG
- Select Launch instance
Create EC2 in a Private subnet
1. In the EC2 interface
- Select Instances
- Select Launch instances
2 .Name and tags, enter EC2 Private
3. Make instance type selection. Key pair name, select aws-keypair
4. Configure Network
- VPC, select ASG vpc
- Subnet, select Private subnet 2, SG choose Private subnet - SG
- Auto-assign public IP, select Disable. If not Disable, you need to check the configuration automatically allocate public IP for the subnet.
• TEST CONNECTION
• Go to the EC2 page
• Select Instances
• Select EC2 Public
• Select Details
• View Public IPv4 address
• Using Mobaxterm, putty… to connect EC2
• Check the connection to the internet of EC2 Public, we execute the command: ping amazon.com -c5
• Make a ping to EC2 private : ping <IP Private EC2 Private>
• Connect to the EC2 Private server and check the internet connection.
4. Access to VPC
5. Select NAT Gateways
6. Create NAT gateway
7. In NAT gateway interface
Edit routes
• Test ping amazon.com successfully from EC2 Private.
• ping amazon.com -c5
• Check Resource MAP
• USING REACHABILITY ANALYZER
• Using Reachability Analyzer
Access to VPC interface
Search Reachability Analyzer
Select Create and analyze path
• Implement Path Configuration
• Name tag, enter EC2 private with EC2 Public
• For Source type, select Instance
• Select source as EC2 Public
• For Destination type, select Instance
• For Destination, select EC2 Private
• The remaining parameters are left to default.
• Select Create and analyze path
• CONFIGURING SITE TO SITE VPN
• Chúng ta có thể kết nối trung tâm dữ liệu On-premise với Amazon VPC bằng VPN cứng hoặc mềm tùy theo mục đích và nhu cầu sử dụng thực tế. Để thiết lập kết
nối VPN Site-to-Site, chúng tôi sẽ cần tạo và định cấu hình VPG Cổng riêng ảo và Cổng khách hàng CGW.
• Virtual Private Gateway (VPG) là trung tâm điều khiển kết nối virtual private network (VPN) được cài đặt trên AWS.
• A Customer Gateway (CGW) là thành phần đại diện cho thiết bị VPN cứng hoặc mềm được cài đặt ở đầu Client end.
• VPN tunnel sẽ được thiết lập ngay khi lưu lượng dữ liệu được truyền giữa AWS và mạng của khách hàng.
• Trong kết nối đó, bạn phải chỉ định loại định tuyến sẽ được sử dụng để đảm bảo an toàn và chất lượng truyền dữ liệu.
• Nếu CGW ở phía Client end hỗ trợ Border Gateway Protocol (BGP), thì trong cấu hình kết nối VPN, chúng tôi được yêu cầu đặt định tuyến thành định tuyến động.
Nếu không, chúng ta phải định cấu hình định tuyến kết nối là định tuyến tĩnh. Trong trường hợp sử dụng định tuyến tĩnh, bạn phải nhập chính xác các tuyến cần
thiết cho kết nối từ phía Máy khách đến VPG được thiết lập ở đầu AWS.
• (Muốn tìm hiểu BGP là gì thì xem link https://quantrimang.com/cong-nghe/border-gateway-protocol-bgp-178019)
• Amazon VPC cung cấp nhiều loại CGW và mỗi CGW được gán cho một VPG, nhưng 1 VPG có thể được liên kết với nhiều CGW (thiết kế nhiều-một). Để hỗ trợ mô
hình này, địa chỉ IP của CGW phải là duy nhất trong một khu vực. Amazon VPC cũng cung cấp thông tin cần thiết để Quản trị viên mạng có thể định cấu hình CGW
và thiết lập kết nối VPN với VPG trên AWS. Kết nối VPN luôn bao gồm 2 Internet Protocol Security (IPSec) để đảm bảo tính sẵn sàng cao của kết nối. Dưới đây là các
tính năng quan trọng mà chúng ta cần biết về VPG, CGW và VPN:
• VPG là thành phần đầu cuối của đường hầm VPN nằm trên AWS.
• CGW có thể là một thiết bị phần cứng hoặc một ứng dụng phần mềm nằm ở đầu Client end trong kết nối VPN tunnel.
CREATE VPC FOR VPN
Create a VPN environment
Access VPC interface
Select Yours VPC
Select Create VPC
In the Create VPC interface
• Save
In the VPC interface
Select Internet Gateway
Select Create internet gateway
Create internet gateway
Name : Internet Gateway VPN
Actions
Attact to VPC
Select VPC ASG VPN
• Create Route Table
• Name : Route table VPN – Public
• VPC : ASG VPN
• Edit route
• Add route :
- Fill in the Destination CIDR : 0.0.0.0/0
representing the Internet.
- In the Target section select Internet Gateway,
then select the Internet Gateway VPN we created
• Select Subnet associations
• Select Edit subnet associations
• Select subnet VPN Public.
• Select Save associations
• Create SG in VPC interface
• Name : VPN Public –SG
• Description : Allow IPSec, SSH, and Ping for servers in public subnet.
• VPC, select ASG VPN vpc
• Create EC2
• Name : Customer Gateway instance
• AMI : same every EC2 are created before
• Network
• CONFIGURING VPN CONNECTION
• In this step we will proceed to create Virtual Private Gateway, Customer
• Gateway and VPN Site to Site connection.
• Create Virtual Private Gateway
• Access to VPC
• Select Virtual Private Gateway
• Select Create Virtual Private Gateway
• Name : VPN Gateway
• Actions
• Attach to VPC
• Select VPC ASG
• CREATE CUSTOMER GATEWAY
• Select Customer Gateways
• Select Create Customer Gateway
• Name : Customer Gateway
• IP address, enter public IP address of the server EC2 Customer Gateway.
• CREATE VPN CONNECTION
• Select Site-to-Site VPN Connections
• Select Create VPN Connection
• Select Download.
• Install OpenSwan
• sudo su
• yum install openswan -y
• Check the configuration file /etc/ipsec.conf
• vi /etc/ipsec.conf
• Configuration file /etc/sysctl.conf
• vi /etc/sysctl.conf
• Move down to the last position in the configuration file. Press the i key to proceed with editing the file.
• Add the following configuration at the end of the configuration file.
net.ipv4.ip_forward = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
sysctl -p
• Next we will configure the file /etc/ipsec.d/aws.conf
• vi /etc/ipsec.d/aws.conf
• Since we only have 1 public IP addres for Customer Gateway, we will need to configure overlapip=yes.
• leftid: IP Public Address on the Onprem side. (Here is public IP of EC2 Customer Gateway in ASG VPN VPC) .
• leftsubnet: CIDR of Local Side Network (If there are multiple network layers, you can leave it as 0.0.0.0/0).
•
• Create and configure the file etc/ipsec.d/aws.secrets Create a new file with the following configuration to set up authentication for the 2 Tunnels.
• touch /etc/ipsec.d/aws.secrets
• vi /etc/ipsec.d/aws.secrets
• Add the following configuration to the end of the configuration file (this configuration is in step 5 of IPSEC Tunnel #1 and IPSEC Tunnel #2)
After completing the configuration.Try to ping from the EC2 Private server side to
the Customer Gateway server. If the VPN configuration is successful you will get the result as
below.
• Modify AWS VPN Tunnel
Access to VPC interface
Select Site-to-Site VPN connections
Select VPN just created.
Select Actions
Select Modify VPN tunnel options
• Go to Cloudwatch to view event logs