Route53 Hybrid DNS
1. VPC 생성
- cloud: 10.0.0.0/16
- onprem: 192.168.0.0/16
- subnets, route tables, nat gateways 생성
2. 인스턴스 생성
cloud-app-server
- sg: ssh anywhere, icmp 192.168.0.0/16
onprem-app-server
- sg: ssh 192.168.0.0/16, icmp 10.0.0.0/16
onprem-vpn-server
- sg: ssh anywhere, dns (udp) 192.168.0.0/16, icmp 192.168.0.0/16
3. VPN 설정
1) Virtual private gateway (cloud-vgw)
2) Customer gateways (onprem-cgw) - onprem-vpn-server의 public IP address (Specify the IP address for your customer gateway device's external interface.)
3) VGW - attach to VPC: cloud-vpc
4) Site-to-Site VPN connections (cloud-onprem-vpn-connection)
- Routing options: Static
- Static IP prefixes: 192.168.0.0/16 (onprem-vpn range)
5) download VPN connections configurations - Platform: Openswan
4. SSH 접속
brew install putty
putty
Auth - Credentials - keypair.pem 경로
Session - Saved Sessions
IP: onprem-vpn-server's public IP
login as: ec2-user
ssh -i "ap-south-1-keypair.pem" ec2-user@35.x.x.x
% sudo su
sh-3.2# ssh -i "ap-south-1-keypair.pem" ec2-user@35.154.187.78
The authenticity of host '35.x.x.x (35.x.x.x)' can't be established.
ED25519 key fingerprint is SHA256:qOx9yHXTxD6xaC9BfiT/Y5/82Ml/mVZzr5hNXnw9FQ8.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '35.x.x.x' (ED25519) to the list of known hosts.
, #_
~\_ ####_ Amazon Linux 2023
~~ \_#####\
~~ \###|
~~ \#/ ___ https://aws.amazon.com/linux/amazon-linux-2023
~~ V~' '->
~~~ /
~~._. _/
_/ _/
_/m/'
[ec2-user@ip-192-168-0-220 ~]$
sudo yum install libreswan
sudo vi /etc/sysctl.conf
1) Open /etc/sysctl.conf and ensure that its values match the following:
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.accept_source_route = 0
2) Apply the changes in step 1 by executing the command 'sysctl -p'
sudo sysctl -p
3) Open /etc/ipsec.conf and look for the line below. Ensure that the # in front of the line has been removed, then save and exit the file.
#include /etc/ipsec.d/*.conf
이미 제거된 상태로 저장됨
cat /etc/ipsec.conf
4) Create a new file at /etc/ipsec.d/aws.conf if doesn't already exist, and then open it. Append the following configuration to the end in the file:
#leftsubnet= is the local network behind your openswan server, and you will need to replace the <LOCAL NETWORK> below with this value (don't include the brackets). If you have multiple subnets, you can use 0.0.0.0/0 instead.
#rightsubnet= is the remote network on the other side of your VPN tunnel that you wish to have connectivity with, and you will need to replace <REMOTE NETWORK> with this value (don't include brackets).
conn Tunnel1
authby=secret
auto=start
left=%defaultroute
leftid=35.x.x.x
right=13.x.x.x
type=tunnel
ikelifetime=8h
keylife=1h
phase2alg=aes128-sha1;modp1024
ike=aes128-sha1;modp1024
auth=esp
keyingtries=%forever
keyexchange=ike
leftsubnet=<LOCAL NETWORK>
rightsubnet=<REMOTE NETWORK>
dpddelay=10
dpdtimeout=30
dpdaction=restart_by_peer
sudo vi /etc/ipsec.d/aws.conf
conn Tunnel1
authby=secret
auto=start
left=%defaultroute
leftid=35.x.x.x
right=13.x.x.x
type=tunnel
ikelifetime=8h
keylife=1h
phase2alg=aes256-sha1;modp2048
ike=aes256-sha1;modp2048
keyingtries=%forever
keyexchange=ike
leftsubnet=192.168.0.0/16
rightsubnet=10.0.0.0/16
dpddelay=10
dpdtimeout=30
dpdaction=restart_by_peer
5) Create a new file at /etc/ipsec.d/aws.secrets if it doesn't already exist, and append this line to the file (be mindful of the spacing!):
35.x.x.x 13.x.x.x: PSK "TOC3RK--------------------IUtns"
sudo vi /etc/ipsec.d/aws.secrets
Tunnel 1 구성 완료
sudo systemctl start ipsec.service
sudo systemctl status ipsec.service
5. Route Tables 설정 (propagation)
cloud-vpc-private-rt > Route propagation > Propagation: Enable
또는 Routes 편집 (cloud-vgw)
cloud-vpc-public-rt도 동일하게 설정
6. VPN 서버의 목적지 비활성화
Instances: onprem-vpn-server > Actions - Networking - Change Source / destination check > check Stop > Save
Route tables: cloud-vpc-public-rt > 10.0.0.0/16 instance (onprem-vpn-server)
7. Cloud Instance 접속
cloud-app-server public IP
ssh -i "ap-south-1-keypair.pem" ec2-user@3.x.x.x
ping (onprem-app-server)
From Cloud EC2 instance - Ping to on-premises App server private IP
Cloud EC2 -> VGW -> VPN Tunnel 1 -> VPN server -> App server
'Networking > AWS' 카테고리의 다른 글
[AWS] VPC - IP Address Manager (0) | 2025.03.11 |
---|---|
[AWS] Route53 Domain hosted zones name server updates (0) | 2025.02.19 |
[AWS] VPC - Basic docs (0) | 2025.02.10 |
[AWS] VPC DNS resolver 우선 순위 (0) | 2025.02.06 |
[AWS] VPC 엔드포인트 서비스를 RDS 프록시에 연결 (cross-account) (0) | 2024.12.10 |