Monday, 8 August 2016

AWS VPC (VPN)


Virtual Private Gateway (VGW)
  • VPN concentrator on VPC side
  • Max 5 per region
  • Represents 2 distinct endpoints in separate data centers (AZs)
    • Each endpoint in distinct AZ (no control which AZs)
    • Two unique public IP addresses
  • Redundancy 
    • Add second CGW that points to the same VGW
    • This creates additional 2 tunnels (total 4 tunnels)
    • No point in adding more VGW in the same VPC
  • Terminates
    • Hardware VPN connection
    • Direct Connect
  • Acts as ECMP route to the set of WAN routers (not Internet routers, compare with IGW)

Customer Gateway (CGW)
  • Represents customer device in the VPN connection
  • Customer-end router supporting IPSec termination
    • This can be software solution
  • Initiates the VPN connection
  • Device may support static or dynamic routing
  • Max 50 per region

AWS Hardware VPN
  • Uses Virtual Private Gateway
  • IPSec based
    • Pre-shared key generated by AWS
    • Uses tunnel mode (no policy based VPN)
    • Customer Gateway must be able to terminate IPSec
  • NAT Traversal (NAT-T) supported
    • Uses UDP/4500 to encapsulate ESP packet
  • Depends on "Internet weather" (latency, jitter)
  • 1 VPN connection -> 1 VPC
    • 1 VPC max 10 VPN connections
    • Max 50 VPN Connections per region
      •  5 VPC per region * 10 VPN connections each
  • 2 endpoints (tunnels) in different AZs for HA
    • Single customer endpoint at minimum
  • You can maintain your on-premise private IP address (no NAT)
  • Routing type
    • Static 
      • Requires routes (IP prefixes) to be manually specifed 
      • Consolidate ACL's to cover all IPs
    • Dynamic  (preferred)
      • Customer device must support single-hop BGP
      • BGP based - announces routes to AWS
        • AWS adds them to the route table in VPC, e.g.
          • 192.168.0.0/16 -> VGW
        • Route propagation
          • Anything I receive on VGW via BGP: add to route table
      • Max-prefixes: 100
      • 2 pr 4 byte AS (Autonomous System) number for both ends
        • Can be changed on both ends
      • Automatically generates BGP IP addresses (link local) for each end, e.g.
        • Tunnel 1
          • AWS: 169.254.169.1/30 
          • Customer: 169.254.169.2/30
        • Tunnel 2
          • AWS: 169.254.169.5/30
          • Customer: 169.254.169.6/30
  • Connections are initiated by Customer Gateway
    • on-premise router sees interesting traffic and initiates session to VGW
    • Fragment IP packets before encryption
    • Reason why there is no VGW<->VGW Hardware VPN
      • Who would initiate
    • Keepalive required to keep the tunnel up
  • 1 unique IPSec Security Association (SA) pair per tunnel
    • 1 inbound and 1 outbound 
    • Total: 2 unique pairs for 2 tunnels = 4 SA
  • HA
    • Use two customer gateway connections cross wired (i.e. 4 tunnels total)
      • Routing on-premise to decide which one to use

Software VPN
  • Run EC2 instance acting as VPN server ("Software VPN Appliance")
    • OpenSwan - IPSec based
    • OpenVPN - SSL based
    • Commercial: Fortinet, Cisco, Check Point, Microsoft, Astaro
  • Customer can manage both ends of VPN (unlike AWS Hardware VPN)
    • Responsible for HA


SSL VPN
  • Clientless
    • Uses browser
    • Non Web applications must use Java/ActiveX controls
  • SSL used as tunnel to access internal application
  • May use special "Portal" (Gateway)
  • Layer 6/7
  • Use cases:
    • remote access
    • roaming client

Misc (Data Transfer)

EU prices

EC2 
  • IN to EC2 from
    • Free
      • Internet
      • Another AWS region
      • S3, Glacier, DynamoDB, SES, SQS, SimpleDB
        • same region
      • EC2, RDS,Redshift, ElastiCache, ENI
        • Same AZ and using private IP
    • Paid (1 GB = $0.01)
      • EC2, RDS,Redshift, ElastiCache, ENI
        • same AZ but using public IP or EIP
        • different AZ
        • peered VPC
      • Billing: "Data Transfer" (regional data transfer)
  • OUT from EC2 to
    • Free
      • S3, Glacier, DynamoDB, SES, SQS, SimpleDB
        • same region 
      • EC2, RDS, Redshift, ElastiCache, ENI
        • same AZ and using private IP
      • CloudFront (origin fetch)
    • Paid
      • (1 GB = $0.01)
        • EC2, RDS, Redshift, ElastiCache, ENI
          • same AZ but using public IP or EIP
          • different AZ
          • peered VPC
        • Billing: "Data Transfer" (regional data transfer)
      • (1 GB = $0.02)
        • another AWS region
      • (1 GB = $0.09)
        • Internet
        • Billing: "Data Transfer"  (data transfer out)

CloudFront
  • OUT to
    • Internet
      • Paid (1GB = $0.085)
    • Origin
      • Paid (1GB = $0.020)
    • Billing: "CloudFront" section

ELB
  • Paid ( 1GB = $0.008)
    • Processed traffic (IN/OUT)
  • Billing: "Elastic Cloud Compute" section