Configure Customer Gateway

Configuring Customer Gateway

  1. Access VPC

    • Select Site-to-Site VPN Connection
    • Choose the VPN Connection you created
    • Click Download Configuration

    VPN Configuration

  2. In the Download Configuration dialog, choose the appliance that fits your environment. For this lab, we will use Strongswan:

    • Vendor: Choose Strongswan
    • Platform: Ubuntu 16.04
    • Software: Strongswan 5.5.1+
    • IKE version: ikev1
    • Click Download.

VPN Configuration

  1. Save the configuration file to the directory where you keep your key pair and other lab tools.
    • Then, based on the downloaded configuration, update the details to match your own device.

VPN Configuration

  • SSH into the EC2 Customer Gateway.

VPN Configuration

  1. Configure the /etc/sysctl.conf file
vi /etc/sysctl.conf

VPN Configuration

  • Move to the end of the file and press i to enter insert mode.
  • Add the following lines to the end of the file:
net.ipv4.ip_forward = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
  • Press ESC, then type :wq! to save and exit the file.

VPN Configuration

  1. Apply this configuration by running:
sysctl -p

VPN Configuration

  1. Install Strongswan
sudo su
amazon-linux-extras install epel -y
yum install strongswan -y

VPN Configuration

  1. After installation, you should see the following files and folders.
ls -la /etc/strongswan/

VPN Configuration

  1. Configure the ipsec.conf file
vi /etc/strongswan/ipsec.conf

VPN Configuration

  • Run :%d to delete all existing content.
  • Press i to enter insert mode.
  • Add the configuration below. We will create 2 tunnels using the information from the VPN Connection configuration file you downloaded earlier and saved alongside your key pair.
  • Make sure you update the IP addresses and network CIDRs to match your own environment before copying the configuration below.
  • leftid: the public IP address on the on-premises side (here, this is the public IP of the EC2 Customer Gateway in the ASG VPN VPC).
  • right: the public IP address on the AWS VPN tunnel side.
  • leftsubnet: the CIDR of the local-side network (if you have multiple networks, you can use 0.0.0.0/0).
  • rightsubnet: the CIDR of the private subnet on AWS.
  • Press ESC, then type :wq! to save the configuration file.
conn Tunnel1
    authby=secret
    auto=start
    left=%defaultroute
    leftid=YOUR_ONPREM_PUBLIC_IP
    right=AWS_VPN_TUNNEL1_IP
    ike=aes128-sha1-modp1024
    esp=aes128-sha1-modp1024
    keyexchange=ike
    ikelifetime=8h
    keylife=1h
    dpdaction=restart
    dpddelay=10s
    dpdtimeout=30s
    leftsubnet=10.11.0.0/16
    rightsubnet=10.10.0.0/16
    type=tunnel

conn Tunnel2
    authby=secret
    auto=start
    left=%defaultroute
    leftid=YOUR_ONPREM_PUBLIC_IP
    right=AWS_VPN_TUNNEL2_IP
    ike=aes128-sha1-modp1024
    esp=aes128-sha1-modp1024
    keyexchange=ike
    ikelifetime=8h
    keylife=1h
    dpdaction=restart
    dpddelay=10s
    dpdtimeout=30s
    leftsubnet=10.11.0.0/16
    rightsubnet=10.10.0.0/16
    type=tunnel

VPN Configuration

  1. Edit /etc/strongswan/ipsec.secrets to set up authentication for the 2 tunnels.
    • Run vi /etc/strongswan/ipsec.secrets to create the file.
    • Run :%d to delete all existing content.
    • Add the following to the end of the configuration file (this information comes from step 4 of IPSEC Tunnel #1 and IPSEC Tunnel #2):
13.208.242.73 13.208.84.230 : PSK "g2XToPyWlZALYxaIRtEkmrMV1vbh_IYR"
13.208.242.73 13.208.68.96 : PSK "EGBSrQnCXxJ881JL_Q3V1rMM1DpbL5RY"

VPN Configuration

  • Press ESC, then type :wq! to save the configuration file.
  • Run cat /etc/strongswan/ipsec.secrets to verify the contents of the configuration file.

VPN Configuration

  1. Start strongSwan:

    • Enable and start strongSwan:
    sudo systemctl enable strongswan
    sudo systemctl start strongswan
    sudo systemctl status strongswan
    

    VPN Configuration

  2. Check the connection status:

    • Check the VPN status with the command:
    sudo swanctl --list-conns
    

    VPN Configuration

    • Check the status of the PSK (Pre-Shared Key):
    sudo swanctl --list-sas
    

    VPN Configuration

    Note the in and out rows — these represent the data received and sent through the tunnel. Right now, it should be 0 bytes.

    Checking the Tunnel Details of the VPN connections in the AWS Console, the status of both tunnels should now be Up.

    VPN Configuration

  3. Once configuration is complete, try pinging from the Customer Gateway server to the EC2 Private server. If the VPN configuration was successful, you should get a result like the one below.

ping <EC2 Private IP> -c5

VPN Configuration

VPN Configuration

  1. Now try pinging from the EC2 Private server back to the Customer Gateway server.
ping <Customer Gateway IPV4> -c5

VPN Configuration

VPN Configuration

  1. Let’s check the traffic flowing through the tunnel:
sudo swanctl --list-sas

VPN Configuration

We have now successfully deployed a Site-to-Site VPN with a Transit Gateway using the strongSwan vendor.