0%

๐Ÿ›ก AWS VPN Site to Site with Dynamic Route

์ž‘์„ฑ์ž : gasida.cloudnet@


AWS Document Link
  • Site-to-Site VPN User Guide
  • Site-to-Site VPN Network Administrator Guide
  • VYOS User Guide


1. AWS VPN Site to Site with Dynamic Route (BGP)

  • VPN ์„ ํ†ตํ•œ ๋‚ด๋ถ€ ๋„คํŠธ์›Œํฌ ๋Œ€์—ญ์— ๋Œ€ํ•œ ๋ผ์šฐํŒ… ๊ด‘๋กœ๋ฅผ BGP ๋ฅผ ํ†ตํ•˜์—ฌ ๋™์ ์œผ๋กœ ์—…๋ฐ์ดํŠธ ํ•œ๋‹ค

  • BGP AS ๋Š” 2- or 4-byte ASN ๋ฅผ ์‚ฌ์šฉ

  • AWS VGW๋Š” BGP๋กœ Amazon VPC ๋Œ€์—ญ์„ ๊ด‘๊ณ ํ•œ๋‹ค

    โ†’ ์ฆ‰, IDC(๊ณ ๊ฐ์ธก)์—๋Š” AWS VPC๋Œ€์—ญ์˜ ๋„คํŠธ์›Œํฌ ์ •๋ณด๋ฅผ ์•Œ๊ฒŒ ๋œ๋‹ค

  • AWS VGW๋Š” BGP๋กœ VPC๋Œ€์—ญ ๊ด‘๊ณ  ์‹œ BGP MED 100 ๊ณผ 200 ์„ ๊ฐ๊ฐ Tunnel ๋กœ ๊ด‘๊ณ ํ•œ๋‹ค

    โ†’ ์ฆ‰, IDC(๊ณ ๊ฐ์ธก)์—์„œ๋Š” BGP MED 100์ด ์šฐ์„ ํ•จ์œผ๋กœ 1๊ฐœ์˜ Tunnel ์ด ์„ ์ •๋˜๊ณ  ์‹ค์ œ ํŠธ๋ž˜ํ”ฝ์ด ํ•ด๋‹น Tunnel ๋กœ ํ†ต์‹ ํ•œ๋‹ค

  • IPsec tunnels ๊ณผ BGP sessions ๋Š” ํ•ญ์ƒ ๊ณ ๊ฐ์ธก(CGW)์—์„œ ์‹œ์ž‘ํ•œ๋‹ค



2. AWS VPN Site to Site with Dynamic Route (BGP) Lab Preview


2.1 Lab Topology

  • ์„œ์šธ, ์‹ฑ๊ฐ€ํด Region์— ๊ฐ๊ฐ AWS ํ™˜๊ฒฝ๊ณผ, IDC ํ™˜๊ฒฝ(๊ฐ€์ •)์œผ๋กœ ๊ตฌ์„ฑ

    • IDC ํ™˜๊ฒฝ์€ ์‹ค์ œ AWS ์˜์—ญ์ด ์•„๋‹ˆ๋ผ ์ผ๋ฐ˜ ๊ธฐ์—… ๋ฌผ๋ฆฌ๋ง์ด์ง€๋งŒ ์‹ค์Šต์˜ ํŽธ๋ฆฌ์„ฑ์„ ์œ„ํ•ด์„œ AWS ํ™˜๊ฒฝ์—์„œ ๊ตฌ์„ฑํ•จ
  • ์„œ์šธ Region ์€ AWS VGW๋ฅผ ๋ฐฐ์น˜ํ•˜๊ณ  Public Subnet ์— ํ…Œ์ŠคํŠธ ์šฉ๋„์˜ EC2๋ฅผ ๋ฐฐ์น˜ํ•จ

  • ์‹ฑ๊ฐ€ํด Region (IDCํ™˜๊ฒฝ)์€ VPN ์—ญํ• ์„ VYOS(์ปค๋ฎค๋‹ˆํ‹ฐAMI)๋กœ ํ•˜๋ฉฐ Private Subnet์— ํ…Œ์ŠคํŠธ ์šฉ๋„์˜ EC2๋ฅผ ๋ฐฐ์น˜ํ•จ

    AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/Untitled.png

๐Ÿ’ก VYOS๋Š” ๋ฆฌ๋ˆ…์Šค(Debina) ๊ธฐ๋ฐ˜์— ๋ผ์šฐํŒ…, ๋ฐฉํ™”๋ฒฝ, VPN ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜์—ฌ VPN ์—ญํ• ๋กœ ์„ ํƒํ•จ. ์ฐธ๊ณ  ๋งํฌ


2.2 ๊ธฐ๋ณธ ์„ค์ •

  • ๋ณธ ์‹ค์Šต์—์„œ ํ™œ์šฉํ•  AWS Region์€ ์„œ์šธ, ์‹ฑ๊ฐ€ํด ์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น Region์— ๋Œ€ํ•œ EC2-Key Pair๋ฅผ ์ƒ์„ฑ
  • ์‹œ๋“œ๋‹ˆ, ์ƒํŒŒ์šธ๋ฃจ Region ์— ๋ฆฌ์†Œ์Šค๋Š” CloudFormation์— ์˜ํ•ด 2.1 ๊ทธ๋ฆผ์˜ ์ธํ”„๋ผ๋ฅผ ์ž๋™ ๊ตฌ์ถ• (2.3ํ•ญ์—์„œ ์ง„ํ–‰)

2.3 CloudFormation (Infrastructure as Code)

์‹ฑ๊ฐ€ํด Region์—์„œ CloudFormation ์Šคํƒ์„ ์ƒ์„ฑํ•œ๋‹ค.
  • 1๋‹จ๊ณ„ ํ…œํ”Œ๋ฆฟ ์ง€์ •
    • ํ…œํ”Œ๋ฆฟ ์ค€๋น„ : ์ค€๋น„๋œ ํ…œํ”Œ๋ฆฟ
    • ํ…œํ”Œ๋ฆฟ ์†Œ์Šค : Amazon S3 URL
    • Amazon S3 URL : https://s3.ap-northeast-2.amazonaws.com/cloudformation.cloudneta.net/VPN/gasida_vpn_idc1.yaml
      • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 2๋‹จ๊ณ„ ์Šคํƒ ์„ธ๋ถ€ ์ •๋ณด ์ง€์ •
    • ์Šคํƒ ์ด๋ฆ„ : VPN-IDC
    • KeyName : ์ž์‹ ์˜ EC2-Key Pair ๋ฅผ ์ง€์ •
      • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 3๋‹จ๊ณ„ ์Šคํƒ ์˜ต์…˜ ๊ตฌ์„ฑ
    • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 4๋‹จ๊ณ„ ๊ฒ€ํ† 
    • ์šฐ์ธก ํ•˜๋‹จ ์Šคํƒ ์ƒ์„ฑ ํด๋ฆญ
์‹ฑ๊ฐ€ํด Region์—์„œ CloudFormation ์Šคํƒ ์ƒ์„ฑ ์™„๋ฃŒ ํ›„ (5๋ถ„ ์ •๋„ ์†Œ์š”) ์ถœ๋ ฅ์—์„œ VYOSInstancePublicIP ์˜ ๊ฐ’(IP)๋ฅผ ํ™•์ธํ•œ๋‹ค.

AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/Untitled%201.png

์„œ์šธ Region์—์„œ CloudFormation ์Šคํƒ์„ ์ƒ์„ฑํ•œ๋‹ค.
  • 1๋‹จ๊ณ„ ํ…œํ”Œ๋ฆฟ ์ง€์ •
    • ํ…œํ”Œ๋ฆฟ ์ค€๋น„ : ์ค€๋น„๋œ ํ…œํ”Œ๋ฆฟ
    • ํ…œํ”Œ๋ฆฟ ์†Œ์Šค : Amazon S3 URL
    • Amazon S3 URL : https://s3.ap-northeast-2.amazonaws.com/cloudformation.cloudneta.net/VPN/gasida_vpn_aws.yaml
      • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 2๋‹จ๊ณ„ ์Šคํƒ ์„ธ๋ถ€ ์ •๋ณด ์ง€์ •
    • ์Šคํƒ ์ด๋ฆ„ : VPN-AWS
    • KeyName : ์ž์‹ ์˜ EC2-Key Pair ๋ฅผ ์ง€์ •
    • StaticRoutesOnlyForVPN : false โ† AWS VPN ์™€ IDC VPN ๊ฐ„ Dynamic Route(BGP) ์„ค์ •์„ ํ•  ์˜ˆ์ •์ด๋ฏ€๋กœ
    • VPCAWSCustomerGatewayIP : 52.76.100.41 โ† ์œ„ ์‹ฑ๊ฐ€ํด์—์„œ ์Šคํƒ ์ถœ๋ ฅ์—์„œ VYOSInstancePublicIP ๊ฐ’
      • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 3๋‹จ๊ณ„ ์Šคํƒ ์˜ต์…˜ ๊ตฌ์„ฑ
    • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 4๋‹จ๊ณ„ ๊ฒ€ํ† 
    • ์šฐ์ธก ํ•˜๋‹จ ์Šคํƒ ์ƒ์„ฑ ํด๋ฆญ
  • CloudFormation์— ์˜ํ•ด ์ƒ์„ฑ๋˜๋Š” ๋ฆฌ์†Œ์Šค๋Š” ์•„๋ž˜์™€ ๊ฐ™์œผ๋ฉฐ, ๊ฐ Region ๋ณ„ ์ •์ƒ์ ์œผ๋กœ ์ƒ์„ฑ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.
์‹ฑ๊ฐ€ํด CloudFormation ์ƒ์„ฑ ์ธํ”„๋ผ
- VPC, 2 Subnet, IGW, 2 Route table
- EIP, VYOS EC2 Instance (eth0, eth1)
- Amazon Linux 2 EC2 Instance (Test์šฉ)
์„œ์šธ CloudFormation ์ƒ์„ฑ ์ธํ”„๋ผ
- VPC, 2 Subnet, IGW, 2 Route table
- VGW, CGW, VPN Connection
- EIP, Amazon Linux 2 EC2 Instance (Test์šฉ)

๐Ÿ’ก ์‹ค๋ฌด์—์„œ์˜ AWS VGW ์™€ ์—ฐ๊ฒฐ ์‹œ IDC ์œ„์น˜ํ•œ VPN(์˜ˆ. VYOS)์„ค์ •์€ ๋ณดํ†ต โ€˜IDC ๋„คํŠธ์›Œํฌ(ํ˜น์€ ๋ณด์•ˆ) ์—”์ง€๋‹ˆ์–ดโ€™ ๊ฐ€ ์„ค์ •์„ ํ•˜๊ฒŒ ๋˜์–ด์„œ ๊ฐœ๋ฐœ์ž ๋ถ„๋“ค์˜ ๊ฒฝ์šฐ ์•„๋ž˜ Lab ๋”ฐ๋ผํ•˜๊ธฐ๊ฐ€ ์–ด๋ ค์šด ๋ถ€๋ถ„์ด ์žˆ๋‹ค. ๊ทธ๋ž˜์„œ VYOS ๊ด€๋ จ ์„ค์ •๊ณผ IDC1์— ๊ด€๋ จ ์„ค์ •์€ toggle โ€˜โ–ถ๏ธŽโ€™ ์ ‘์–ด ๋‘์—ˆ๋‹ค. ํ•„์š” ์‹œ toggle ํด๋ฆญํ•˜์—ฌ ์ƒ์„ธํžˆ ๋‚ด์šฉ์„ ๋ณด์‹œ๊ธฐ ๋ฐ”๋ž€๋‹ค. VYOS ๋‚ด์šฉ์„ ์ œ์™ธํ•œ AWS VPN ๊ด€๋ จ ์„ค์ • ๋‚ด์šฉ์„ ์œ„์ฃผ๋กœ ๋ณด์‹œ๋ฉด ๋œ๋‹ค.


2.4 ๊ฒ€์ฆ

  • ์‚ฌ์šฉ์ž PC์—์„œ ์‹ฑ๊ฐ€ํด VYOS Public IP ์ฃผ์†Œ๋กœ SSH ์ ‘๊ทผํ•œ๋‹ค. ์ถ”๊ฐ€๋กœ VYOS ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •์„ ํ•œ๋‹ค.

    • VYOS ์„ค์ • ๋ชจ๋“œ(conf) ๋กœ ์ง„์ž…ํ•ด์„œ VYOS eth1 IP(์Šคํƒ ์ถœ๋ ฅ VYOSInstanceINTERNALPrivateIP ํ™•์ธ)๋Š” ์„ค์ • ํ›„ ์ ์šฉํ•œ๋‹ค.

    • Private Subnet ์— ์žˆ๋Š” Test EC2 IP ๋กœ ping ๋ฐ SSH ์ ‘๊ทผํ•œ๋‹ค. ์ ‘์† ๊ณ„์ • root / qwe123

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      # ์ž์‹ ์˜ VYOSInstanceINTERNALPrivateIP ๋กœ SSH ์ ‘์†
      ssh -i '*EC2-Key Pair'* vyos@52.76.100.41
      ..

      # ํ•ด๋‹น AMI ์ด๋ฏธ์ง€๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ eth1 IP ๊ฐ€ ๋ฏธ์„ค์ • ๋˜์–ด ์žˆ๋‹ค
      vyos@ip-10-100-1-198:~$ show interfaces
      Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
      Interface IP Address S/L Description
      --------- ---------- --- -----------
      eth0 10.100.1.198/24 u/u
      eth1 - u/u
      ..

      # VYOS ์„ค์ •๋ชจ๋“œ(conf)๋กœ ์ง„์ž…ํ•˜์—ฌ eth1์˜ IP๋ฅผ ์„ค์ • ํ›„ ์ ์šฉ๊ณผ ์ €์žฅ์„ ํ•œ๋‹ค
      vyos@ip-10-100-1-198$ conf
      vyos@ip-10-100-1-198# set interfaces ethernet eth1 address 10.100.100.56/24
      vyos@ip-10-100-1-198# commit
      vyos@ip-10-100-1-198# exit

      # VYOS์—์„œ ๋‚ด๋ถ€์— ์žˆ๋Š” EC2 ์ธ์Šคํ„ด์Šค๋กœ ping ํ…Œ์ŠคํŠธ๋ฅผ ํ•œ๋‹ค
      vyos@ip-10-100-1-198:~$ ping 10.100.100.192
      PING 10.100.100.192 (10.100.100.192) 56(84) bytes of data.
      64 bytes from 10.100.100.192: icmp_seq=1 ttl=255 time=0.732 ms
      ..

      # VYOS์—์„œ ๋‚ด๋ถ€์— ์žˆ๋Š” EC2 ์ธ์Šคํ„ด์Šค๋กœ SSH ์ ‘์† ํ™•์ธ์„ ํ•œ๋‹ค.
      vyos@ip-10-100-1-198:~$ ssh root@10.100.100.192
  • ์‚ฌ์šฉ์ž PC์—์„œ ์„œ์šธ EC2 Instance EIP ์ฃผ์†Œ๋กœ SSH ์ ‘๊ทผํ•œ๋‹ค. ์ ‘์† ๊ณ„์ • root / qwe123

    1
    ssh root@52.78.176.204
  • ์ฐธ๊ณ ๋กœ CloudFormation์— ์˜ํ•ด ๋ฆฌ์†Œ์Šค๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์˜ฌ๋ผ์˜ค๊ธฐ ๊นŒ์ง€ ์•ฝ๊ฐ„์˜ ์‹œ๊ฐ„์ด ํ•„์š”ํ•˜๋‹ˆ ์ผ์ • ์‹œ๊ฐ„ ๋Œ€๊ธฐ๊ฐ€ ํ•„์š”ํ•˜๋‹ค.

๐Ÿ’ก ๋ณธ๊ฒฉ์ ์ธ ์‹ค์Šต์— ์•ž์„œ, Site to Site VPN ๋ฆฌ์†Œ์Šค๋Š” ์†Œ๋Ÿ‰์˜ ๊ณผ๊ธˆ์ด ๋ถˆ๊ฐ€ํ”ผ ํ•˜๋‹ค. (VPN ์—ฐ๊ฒฐ ์‹œ๊ฐ„ ๋‹จ์œ„ ์š”๊ธˆ ๋ถ€๊ณผ - ์‹œ๊ฐ„ ๋‹น $0.05 ๋“ฑ)
์ž์„ธํ•œ ์‚ฌํ•ญ์€ ์š”๊ธˆ ๋งํฌ๋ฅผ ์ฐธ๊ณ  ๋ฐ”๋ž€๋‹ค.



3. Configuration Site to Site VPN


3.1 ์„œ์šธ Region ์˜ VPN ์ •๋ณด ํ™•์ธ

  • VPN Tunnel 1 ๊ณผ Tunnel 2 ์˜ ์™ธ๋ถ€IP์™€ ๋‚ด๋ถ€IP CIDR์„ ํ™•์ธ ํ•œ๋‹ค.

    AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/_2020-05-07__10.03.33.png


3.2 ์„œ์šธ Region ์˜ ๊ณ ๊ฐ VPN ์žฅ๋น„ ์„ค์ •์„ ์œ„ํ•œ ๊ตฌ์„ฑ ๋‹ค์šด๋กœ๋“œ ํ›„ ์‹ฑ๊ฐ€ํด Region ์— VYOS ์— VPN Config ์„ค์ •

  • ๐Ÿ’๐Ÿปโ€โ™‚๏ธ VPN ๊ตฌ์„ฑ ๋‹ค์šด๋กœ๋“œ? AWS VGW ์— ์—ฐ๊ฒฐ๋˜๋Š” ๊ณ ๊ฐVPN ์žฅ๋น„(๊ณต๊ธ‰์—…์ฒด ๋ณ„)์˜ VPN ๊ด€๋ จ ์„ค์ •์„ AWS ์—์„œ ์ œ๊ณต

  • [AWS VPN ์‚ฌ์ดํŠธ ๊ฐ„ VPN ์—ฐ๊ฒฐ - ๊ตฌ์„ฑ ๋‹ค์šด๋กœ๋“œ] ์„ ํƒ ํ›„ Vyatta ์„ ํƒ ํ›„ ๋‹ค์šด๋กœ๋“œ

    AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/Untitled%202.png

  • ๋‹ค์šด ๋ฐ›์€ config ํŒŒ์ผ ๋‚ด์šฉ์„ ์ผ๋ถ€ ๋ณ€๊ฒฝ ํ›„ VYOS ์— ์ ์šฉํ•œ๋‹ค

์ผ๋ถ€ ๋‚ด์šฉ ๋ณ€๊ฒฝ : ์ฐพ๊ธฐ ์‚ฌ์šฉ์„ ๊ถŒ์žฅ
1
2
3
4
5
6
7
8
9
10
11
12
13
41์ค„, 132์ค„) VYOS eth0(EIP)๋ฅผ etho(private ip)๋กœ ๋ณ€๊ฒฝ
set vpn ipsec site-to-site peer 15.164.80.217 local-address '10.100.1.198'
set vpn ipsec site-to-site peer 52.78.188.212 local-address '10.100.1.198'

98์ค„, 189์ค„) VYOS ์˜ BGP ๋ช…๋ น์–ด ์ž…๋ ฅ์ด ๋ฒ„์ „ ์ƒํ–ฅ์œผ๋กœ ์ผ๋ถ€ ๋ฐ”๋€Œ์—ˆ์Œ
set protocols bgp 65000 neighbor 169.254.13.29 soft-reconfiguration 'inbound' -(์•„๋ž˜ ๋‚ด์šฉ์œผ๋กœ ๋ณ€๊ฒฝ)->
set protocols bgp 65000 neighbor 169.254.13.29 address-family ipv4-unicast soft-reconfiguration inbound

106์ค„, 197์ค„) ํ•ด๋‹น ๋‚ด์šฉ ์‚ญ์ œ, ํ•ด๋‹น ๋‚ด์šฉ์€ IDC์—์„œ ๋””ํดํŠธ route ์ •๋ณด๋ฅผ ๊ด‘๊ณ ํ•˜๋Š” ๋‚ด์šฉ์ด๋‹ค
set protocols bgp 65000 network 0.0.0.0/0 - ํ•ด๋‹น ์ค„ ๋‚ด์šฉ ์‚ญ์ œ

๋งจ ๋งˆ์ง€๋ง‰์ค„ ๋‚ด์šฉ ์ถ”๊ฐ€) IDC๋‚ด๋ถ€ ๋Œ€์—ญ์ธ 10.100.0.0/16 ๋Œ€์—ญ์„ BGP๋กœ ๊ด‘๊ณ ํ•œ๋‹ค
set protocols bgp 65000 address-family ipv4-unicast network 10.100.0.0/16

๋ณ€๊ฒฝ ์ ์šฉ ํ•œ VYOS VPN Config โ†’ VYOS conf ๋ชจ๋“œ์— ๋ณต์‚ฌ ๋ถ™์—ฌ๋„ฃ๊ธฐ๋ฅผ ํ•œ๋‹ค
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
conf
set vpn ipsec ike-group AWS lifetime '28800'
set vpn ipsec ike-group AWS proposal 1 dh-group '2'
set vpn ipsec ike-group AWS proposal 1 encryption 'aes128'
set vpn ipsec ike-group AWS proposal 1 hash 'sha1'
set vpn ipsec site-to-site peer 15.164.80.217 authentication mode 'pre-shared-secret'
set vpn ipsec site-to-site peer 15.164.80.217 authentication pre-shared-secret 'NCN1B7Xzjv0NnGOLxFQJMnWBG8FlJnzT'
set vpn ipsec site-to-site peer 15.164.80.217 description 'VPC tunnel 1'
set vpn ipsec site-to-site peer 15.164.80.217 ike-group 'AWS'
set vpn ipsec site-to-site peer 15.164.80.217 local-address '10.100.1.198'
set vpn ipsec site-to-site peer 15.164.80.217 vti bind 'vti0'
set vpn ipsec site-to-site peer 15.164.80.217 vti esp-group 'AWS'

set vpn ipsec ipsec-interfaces interface 'eth0'
set vpn ipsec esp-group AWS compression 'disable'
set vpn ipsec esp-group AWS lifetime '3600'
set vpn ipsec esp-group AWS mode 'tunnel'
set vpn ipsec esp-group AWS pfs 'enable'
set vpn ipsec esp-group AWS proposal 1 encryption 'aes128'
set vpn ipsec esp-group AWS proposal 1 hash 'sha1'

set vpn ipsec ike-group AWS dead-peer-detection action 'restart'
set vpn ipsec ike-group AWS dead-peer-detection interval '10'
set vpn ipsec ike-group AWS dead-peer-detection timeout '30'

set interfaces vti vti0 address '169.254.70.182/30'
set interfaces vti vti0 description 'VPC tunnel 1'
set interfaces vti vti0 mtu '1436'

set protocols bgp 65000 neighbor 169.254.70.181 remote-as '64512'
set protocols bgp 65000 neighbor 169.254.70.181 address-family ipv4-unicast soft-reconfiguration inbound
set protocols bgp 65000 neighbor 169.254.70.181 timers holdtime '30'
set protocols bgp 65000 neighbor 169.254.70.181 timers keepalive '10'

set vpn ipsec site-to-site peer 52.78.188.212 authentication mode 'pre-shared-secret'
set vpn ipsec site-to-site peer 52.78.188.212 authentication pre-shared-secret 'MfmyxlydtXvvC2FLGmBsqMQlW5q89Z0S'
set vpn ipsec site-to-site peer 52.78.188.212 description 'VPC tunnel 2'
set vpn ipsec site-to-site peer 52.78.188.212 ike-group 'AWS'
set vpn ipsec site-to-site peer 52.78.188.212 local-address '10.100.1.198'
set vpn ipsec site-to-site peer 52.78.188.212 vti bind 'vti1'
set vpn ipsec site-to-site peer 52.78.188.212 vti esp-group 'AWS'

set interfaces vti vti1 address '169.254.50.254/30'
set interfaces vti vti1 description 'VPC tunnel 2'
set interfaces vti vti1 mtu '1436'

set protocols bgp 65000 neighbor 169.254.50.253 remote-as '64512'
set protocols bgp 65000 neighbor 169.254.50.253 address-family ipv4-unicast soft-reconfiguration inbound
set protocols bgp 65000 neighbor 169.254.50.253 timers holdtime '30'
set protocols bgp 65000 neighbor 169.254.50.253 timers keepalive '10'

set protocols bgp 65000 address-family ipv4-unicast network 10.100.0.0/16

commit
save

  • VPN ๊ด€๋ จ Tunnel, Interface, IP ๋ฅผ ํ‘œํ˜„

    AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/Untitled%203.png



4. Verify Site to Site VPN


4.1 ์„œ์šธ Region ์˜ VPN ์ •๋ณด ํ™•์ธ

  • VPN Tunnel 2๊ฐœ์˜ ์ƒํƒœ๊ฐ€ ์ •์ƒ ์ž‘๋™์„ ํ™•์ธ , ์„ธ๋ถ€์ •๋ณด์—์„œ VYOS ์—์„œ BGP๋กœ 1๊ฐœ์˜ ๋„คํŠธ์›Œํฌ ๋Œ€์—ญ์„ ๊ด‘๊ณ ํ•ด์„œ ์•Œ์•„์™”์Œ์„ ํ™•์ธ

    AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/_2020-05-07__10.45.34.png


4.2 ์‹ฑ๊ฐ€ํด Region ์˜ VYOS ์—์„œ VPN ์ •๋ณด ํ™•์ธ

  • Tunnel ์ธํ„ฐํŽ˜์ด์Šค(= vti0, vti1) ์ •๋ณด ํ™•์ธ ๋ฐ VPN ์ƒํƒœ ํ™•์ธ ๋ฐ ๋ผ์šฐํŒ… ํ…Œ์ด๋ธ” ํ™•์ธ, VPN Tunnel IP ๋กœ ping ํ…Œ์ŠคํŠธ

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    # VYOS ์˜ ๊ฐ€์ƒ์˜ ํ„ฐ๋„ ์ธํ„ฐํŽ˜์ด์Šค ์ •๋ณด๋ฅผ ํ™• 
    $ show interfaces vti
    Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
    Interface IP Address S/L Description
    --------- ---------- --- -----------
    vti0 169.254.70.182/30 u/u VPC tunnel 1
    vti1 169.254.50.254/30 u/u VPC tunnel 2

    # AWS ๋‚ด๋ถ€IP(ํ„ฐ๋„IP)์™€ ping ํ†ต์‹  ํ™•์ธ
    $ ping 169.254.70.181
    64 bytes from 169.254.70.181: icmp_seq=1 ttl=254 time=103 ms
    $ ping 169.254.50.253
    64 bytes from 169.254.50.253: icmp_seq=1 ttl=254 time=103 ms

    # VYOS ์˜ VPN IPsec ์ƒํƒœ ์ •๋ณด ํ™•์ธ ๋ฐ ํ•ด๋‹น ํ„ฐ๋„์„ ํ†ตํ•œ ํŠธ๋ž˜ํ”ฝ ํ†ต๊ณ„ ํ™•์ธ
    $ show vpn ipsec sa
    Connection State Uptime Bytes In/Out Packets In/Out Remote address Remote ID Proposal
    ----------------------------- ------- -------- -------------- ---------------- ---------------- ----------- ----------------------------------
    peer-52.78.188.212-tunnel-vti up 8m23s 4K/6K 62/112 52.78.188.212 N/A AES_CBC_128/HMAC_SHA1_96/MODP_1024
    peer-15.164.80.217-tunnel-vti up 8m23s 5K/6K 84/110 15.164.80.217 N/A AES_CBC_128/HMAC_SHA1_96/MODP_1024

    # VYOS ์žฅ๋น„์˜ ๋ผ์šฐํŒ… ํ…Œ์ด๋ธ”์„ ํ™•์ธ, AWS VGW์— ์—ฐ๊ฒฐ๋œ VPC๋Œ€์—ญ์— ๋Œ€ํ•œ ๋ผ์šฐํŒ… ์ •๋ณด ํ™•์ธ
    $ show ip route
    ..
    S>* 0.0.0.0/0 [210/0] via 10.100.1.1, eth0, 00:52:07
    B>* 10.50.0.0/16 [20/100] via 169.254.50.253, vti1, 00:08:31
    C>* 10.100.1.0/24 is directly connected, eth0, 00:52:08
    C>* 10.100.100.0/24 is directly connected, eth1, 00:47:21
    C>* 169.254.50.252/30 is directly connected, vti1, 00:08:33
    C>* 169.254.70.180/30 is directly connected, vti0, 00:08:33

    # VYOS์™€ VGW ๊ฐ„ BGP ์ •๋ณด ํ™•์ธ, AWS Tunnel1๊ณผ2์—์„œ ๊ฐ๊ฐ Metric(=MED) 100๊ณผ 200์œผ๋กœ ์ธ์ž…
    $ show ip bgp
    ..
    Network Next Hop Metric LocPrf Weight Path
    *> 10.50.0.0/16 169.254.50.253 100 0 64512 i
    * 169.254.70.181 200 0 64512 i
    *> 10.100.0.0/16 0.0.0.0 0 32768 i

    sh ip bgp summary
    sh ip bgp neighbors 169.254.X.Y advertised-routes
    sh ip bgp neighbors 169.254.X.Y received-routes
    sh ip bgp neighbors 169.254.X.Y routes

4.3 ์‹ฑ๊ฐ€ํด ๋‚ด๋ถ€ ๋Œ€์—ญ์˜ Route Table ์„ค์ •

  • [VPC - Route Tables] VPCIDC1 VYOS Internal Subnet Route Table ์„ ํƒ ํ›„ [๋ผ์šฐํŒ… ํŽธ์ง‘]์œผ๋กœ ์ถ”๊ฐ€

    • 10.50.0.0/16 , Network Interface โ†’ VYOS Eth1 ํ›„ ๋ผ์šฐํŒ… ์ €์žฅ

      AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/_2020-05-07__10.57.18.png


4.4 ์„œ์šธ Subnet์— Route Table ์„ค์ •

  • [VPC - Route Tables] VPCAWS Subnet Route Table ์„ ํƒ ํ›„ [๋ผ์šฐํŒ… ์ „ํŒŒ ํŽธ์ง‘]์œผ๋กœ ์ถ”๊ฐ€

    • ์ „ํŒŒ ์„ ํƒ ํ›„ ์ €์žฅ

      AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/_2020-05-06__3.44.45.png

    • ๋ผ์šฐํŒ… ํ…Œ์ด๋ธ”์„ ํ™•์ธํ•˜๋ฉด ์ž๋™์œผ๋กœ ์ถ”๊ฐ€๋˜์–ด ์žˆ๋‹ค

      AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/_2020-05-07__11.05.44.png


4.5 ์ „์ฒด ๋ผ์šฐํŒ… ์ƒํƒœ ํ™•์ธ

  • ์„œ์šธ Region ๊ฒฝ์šฐ ์‹ฑ๊ฐ€ํด VPC๋Œ€์—ญ์ธ 10.100.0.0/16 ์„VGW ๋กœ ๋ณด๋ƒ„

    โ†’ ์ดํ›„ VGW ๋Š” VPN Tunnel ์„ ํ†ตํ•ด VYOS eth0 ์œผ๋กœ ๋ณด๋ƒ„

  • ์‹ฑ๊ฐ€ํด Region ๊ฒฝ์šฐ ๋‚ด๋ถ€๋Œ€์—ญ(10.100.100.0/24)์—์„œ ์„œ์šธ VPC๋Œ€์—ญ์ธ 10.50.0.0/16 ์„ VYOS eth1 ์œผ๋กœ ๋ณด๋ƒ„

    โ†’ ์ดํ›„ VYOS๋Š” 10.50.0.0/16 ์„ vti0, vti1 ์ฆ‰ VPN Tunnel ์„ ํ†ตํ•ด VGW ๋กœ ๋ณด๋ƒ„

    AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/Untitled%204.png


4.6 ํ†ต์‹  ํ™•์ธ

  • ์„œ์šธ EC2 ์—์„œ ์‹ฑ๊ฐ€ํด EC2 ๋กœ ping ํ†ต์‹ , ssh ์ ‘์†์„ ํ™•์ธ

    1
    2
    3
    4
    5
    6
    7
    8
    [root@ip-10-50-1-175 ~]$ ping -c 1 10.100.100.192
    PING 10.100.100.192 (10.100.100.192) 56(84) bytes of data.
    64 bytes from 10.100.100.192: icmp_seq=1 ttl=254 time=103 ms

    $ ssh root@10.100.100.192
    root@10.100.100.192's password:
    ..
    [root@ip-10-100-100-192 ~]#
  • ์œ„ ping ํ†ต์‹  ์‹œ๋„ ์‹œ, VYOS ์—์„œ icmp ํŒจํ‚ท ํ™•์ธ

    1
    2
    3
    4
    5
    vyos@ip-10-100-1-198:~$ sudo tcpdump -i any -nn icmp
    ..
    02:08:35.528632 IP 10.100.100.192 > 10.50.1.175: ICMP echo reply, id 32455, seq 14, length 64
    02:08:36.529260 IP 10.50.1.175 > 10.100.100.192: ICMP echo request, id 32455, seq 15, length 64
    ..

4.7 CloudWatch ๋ชจ๋‹ˆํ„ฐ๋ง ์„ค์ •

  • ์„œ์šธ Region [CloudWatch - ๋Œ€์‹œ๋ณด๋“œ ์ƒ์„ฑ] : ์ด๋ฆ„(VPN)

    • ์œ„์ ฏ ์ถ”๊ฐ€

      • ์œ ํ˜• : ํ–‰

        • ์ง€ํ‘œ : VPN ํ„ฐ๋„ ์ง€ํ‘œ โ†’ (VPN Tunnel 1 IP ์ž…๋ ฅ ํ›„ ๊ฒ€์ƒ‰ ํ›„) TunnelState ์„ ํƒ
          • ๊ทธ๋ž˜ํ”„๋กœ ํ‘œ์‹œ๋œ ์ง€ํ‘œ : ๋ ˆ์ด๋ธ”(VPN Tunnel 1 State), ํ†ต๊ณ„(์ตœ์†Œ), ๊ธฐ๊ฐ„(1๋ถ„)
            • ๊ทธ๋ž˜ํ”„์˜ต์…˜ : ์œ„์ ฏ ์œ ํ˜•(๋ˆ„์  ๋ฉด์ )
              • ์ƒ๋‹จ(์‚ฌ์šฉ์ž์ง€์ • - 30๋ถ„, ํ˜„์ง€์‹œ๊ฐ„๋Œ€)
              • ์šฐ์ธก ํ•˜๋‹จ ์œ„์ ฏ ์ƒ์„ฑ
      • ์œ ํ˜• : ํ–‰

        • ์ง€ํ‘œ : VPN ํ„ฐ๋„ ์ง€ํ‘œ โ†’ (VPN Tunnel 2 IP ์ž…๋ ฅ ํ›„ ๊ฒ€์ƒ‰ ํ›„) TunnelState ์„ ํƒ
          • ๊ทธ๋ž˜ํ”„๋กœ ํ‘œ์‹œ๋œ ์ง€ํ‘œ : ์ƒ‰์ƒ(๋ณ€๊ฒฝ), ๋ ˆ์ด๋ธ”(VPN Tunnel 2 State), ํ†ต๊ณ„(์ตœ์†Œ), ๊ธฐ๊ฐ„(1๋ถ„)
            • ๊ทธ๋ž˜ํ”„์˜ต์…˜ : ์œ„์ ฏ ์œ ํ˜•(๋ˆ„์  ๋ฉด์ )
              • ์ƒ๋‹จ(์‚ฌ์šฉ์ž์ง€์ • - 30๋ถ„, ํ˜„์ง€์‹œ๊ฐ„๋Œ€)
              • ์šฐ์ธก ํ•˜๋‹จ ์œ„์ ฏ ์ƒ์„ฑ
      • ์œ ํ˜• : ํ–‰

        • ์ง€ํ‘œ : VPN ํ„ฐ๋„ ์ง€ํ‘œ โ†’ (VPN Tunnel 1 IP ์ž…๋ ฅ ํ›„ ๊ฒ€์ƒ‰ ํ›„) TunnelDataIn, TunnelDataOut ์„ ํƒ
          • ๊ทธ๋ž˜ํ”„๋กœ ํ‘œ์‹œ๋œ ์ง€ํ‘œ : ์ƒ๋‹จ(VPN Tunnel 1 Data In/Out), ํ†ต๊ณ„(ํ•ฉ๊ณ„), ๊ธฐ๊ฐ„(1๋ถ„)
            • ๊ทธ๋ž˜ํ”„์˜ต์…˜ : ์œ„์ ฏ ์œ ํ˜•(๋ˆ„์  ๋ฉด์ )
              • ์ƒ๋‹จ(์‚ฌ์šฉ์ž์ง€์ • - 30๋ถ„, ํ˜„์ง€์‹œ๊ฐ„๋Œ€)
              • ์šฐ์ธก ํ•˜๋‹จ ์œ„์ ฏ ์ƒ์„ฑ
      • ์œ ํ˜• : ํ–‰

        • ์ง€ํ‘œ : VPN ํ„ฐ๋„ ์ง€ํ‘œ โ†’ (VPN Tunnel 2 IP ์ž…๋ ฅ ํ›„ ๊ฒ€์ƒ‰ ํ›„) TunnelDataIn, TunnelDataOut ์„ ํƒ
          • ๊ทธ๋ž˜ํ”„๋กœ ํ‘œ์‹œ๋œ ์ง€ํ‘œ : ์ƒ๋‹จ(VPN Tunnel 2 Data In/Out), ํ†ต๊ณ„(ํ•ฉ๊ณ„), ๊ธฐ๊ฐ„(1๋ถ„)
            • ๊ทธ๋ž˜ํ”„์˜ต์…˜ : ์œ„์ ฏ ์œ ํ˜•(๋ˆ„์  ๋ฉด์ )
              • ์ƒ๋‹จ(์‚ฌ์šฉ์ž์ง€์ • - 30๋ถ„, ํ˜„์ง€์‹œ๊ฐ„๋Œ€)
              • ์šฐ์ธก ํ•˜๋‹จ ์œ„์ ฏ ์ƒ์„ฑ
      • ์ƒ๋‹จ - ๋Œ€์‹œ๋ณด๋“œ ์ €์žฅ

        AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/Untitled%205.png



5. VPN Failover Test


5.1 ์‹ฑ๊ฐ€ํด Region ์˜ VYOS ์žฌ๋ถ€ํŒ… ํ›„ ํ™•์ธ

  • ์„œ์šธ Region ์˜ ๋‚ด๋ถ€ EC2 ์—์„œ ping ์‹คํ–‰

    1
    $ ping -i 1 -W 1 10.100.100.192
  • VYOS ์ธ์Šคํ„ด์Šค ์žฌ๋ถ€ํŒ…

    1
    vyos@ip-10-100-1-198:~$ reboot now
  • ์„œ์šธ Region ์˜ ๋‚ด๋ถ€ EC2 ์—์„œ ping ๊ฒฐ๊ณผ ํ™•์ธ

    • 82 - 23 = 59๊ฐœ๋กœ ๋Œ€๋žต 59์ดˆ(=๋Œ€๋žต 1๋ถ„) ์ •๋„์˜ ์ ˆ์ฒด์‹œ๊ฐ„์ด ์žˆ์—ˆ๋‹ค.

      1
      2
      3
      4
      5
      6
      7
      8
      $ ping -i 1 -W 1 10.100.100.192
      PING 10.100.100.192 (10.100.100.192) 56(84) bytes of data.
      64 bytes from 10.100.100.192: icmp_seq=1 ttl=254 time=104 ms
      ..
      ^C
      --- 10.100.100.192 ping statistics ---
      82 packets transmitted, 23 received, 71% packet loss, time 82429ms
      rtt min/avg/max/mdev = 103.895/104.418/105.911/0.503 ms
  • CloudWatch ๋ชจ๋‹ˆํ„ฐ๋ง์„ ํ™•์ธ : 2๊ฐœ Tunnel State ๊ฐ€ 0 ์œผ๋กœ ๋‹ค์šด๋˜๊ณ  ์ •์ƒ์ด ๋˜์—ˆ๋‹ค, ํŠธ๋ž˜ํ”ฝ์€ ์—ฌ์ „ํžˆ Tunnel 2 ๋ฅผ ์‚ฌ์šฉ ์ค‘์ด๋‹ค

    AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/_2020-05-07__11.36.58.png


5.2 ํ˜„์žฌ Active VPN Tunnel ์„ Down ํ›„ ํ™•์ธ

  • ํ˜„์žฌ ํ†ต์‹ ์— ์‚ฌ์šฉ๋˜๋Š” VPN Tunnel ์„ ๊ฐ•์ œ๋กœ Down ํ•˜์—ฌ ๋‹ค๋ฅธ VPN Tunnel ์‚ฌ์šฉ ์‹œ๋ฅผ ํ…Œ์ŠคํŠธ ํ•ด๋ณธ๋‹ค

    AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/Untitled%206.png

  • ์„œ์šธ Region ์˜ ๋‚ด๋ถ€ EC2 ์—์„œ ping ์‹คํ–‰

    1
    $ ping -i 1 -W 1 10.100.100.192
  • VYOS ์—์„œ ํ„ฐ๋„ ์ •๋ณด๋ฅผ ํ™•์ธ ํ›„ ํ•ด๋‹น ํ„ฐ๋„๋กœ ๋งบํ˜€์žˆ๋Š” BGP ๋„ค์ด๋ฒ„๋ฅผ ๊ฐ•์ œ๋กœ Shutdown ํ•œ๋‹ค

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    $ show ip route
    B>* 10.50.0.0/16 [20/100] via 169.254.50.253, vti1, 00:00:12

    $ show vpn ipsec sa
    Connection State Uptime Bytes In/Out Packets In/Out Remote address Remote ID Proposal
    ----------------------------- ------- -------- -------------- ---------------- ---------------- ----------- ----------------------------------
    peer-52.78.188.212-tunnel-vti up 15m29s 75K/84K 943/1K 52.78.188.212 N/A AES_CBC_128/HMAC_SHA1_96/MODP_1024
    peer-15.164.80.217-tunnel-vti up 15m29s 13K/11K 190/194 15.164.80.217 N/A AES_CBC_128/HMAC_SHA1_96/MODP_1024

    conf
    set protocols bgp 65000 neighbor 169.254.50.253 shutdown
    commit
    save
    exit

    $ show ip route
    ..
    B>* 10.50.0.0/16 [20/100] via 169.254.70.181, vti0, 00:04:37
  • ์„œ์šธ Region ์˜ ๋‚ด๋ถ€ EC2 ์—์„œ ping ๊ฒฐ๊ณผ ํ™•์ธ

    • 22 - 21 = 1๊ฐœ๋กœ ๋Œ€๋žต 1์ดˆ ์ด๋‚ด์— ์ ˆ์ฒด์‹œ๊ฐ„์ด ์žˆ์—ˆ๋‹ค.

      1
      2
      3
      4
      5
      6
      7
      8
      $ ping -i 1 -W 1 10.100.100.192
      PING 10.100.100.192 (10.100.100.192) 56(84) bytes of data.
      64 bytes from 10.100.100.192: icmp_seq=1 ttl=254 time=104 ms
      ..
      ^C
      --- 10.100.100.192 ping statistics ---
      22 packets transmitted, 21 received, 4% packet loss, time 21029ms
      rtt min/avg/max/mdev = 104.003/104.743/105.439/0.621 ms
  • CloudWatch ๋ชจ๋‹ˆํ„ฐ๋ง์„ ํ™•์ธ : Tunnel 2 ๊ฐ€ Down ๋˜์ž๋งˆ์ž ๋ฐ”๋กœ Tunnel 1 ๋กœ ๋ฐ์ดํ„ฐ ํŠธ๋ž˜ํ”ฝ ํ†ต์‹ ์„ ์‚ฌ์šฉํ–ˆ๋‹ค.

    AWS%20VPN%20Site%20to%20Site%20with%20Dynamic%20Route%20BGP%2005b6a5e86b864ae6b876cae1b8184477/_2020-05-07__11.55.13.png



6. Delete Infrastructure

  • ์‹ฑ๊ฐ€ํด Region ์˜ CloudFormation Stack ์‚ญ์ œ
  • ์„œ์šธ Region ์˜ CloudFormation Stack ์‚ญ์ œ
  • ์„œ์šธ Region ์˜ CloudWatch ๋Œ€์‹œ๋ณด๋“œ ์‚ญ์ œ

Welcome to my other publishing channels