Saturday, July 25, 2015

How to Configure a Site-To-Site IPsec VPN to the Amazon AWS VPN Gateway

How to Configure a Site-To-Site IPsec VPN to the Amazon AWS VPN Gateway

If you are using the Amazon Virtual Private Cloud, you can transparently extend your local network to the cloud by connecting both networks with a site-to-site IPsec VPN tunnel. The Amazon virtual private gateway uses static routing and two parallel IPsec tunnels, of which only one tunnel is used when connecting with the Linux system.


Site - A ( AWS Cloud VPC Side):-

root#sudo yum install openswan

root#sudo vi /etc/ipsec.conf

# /etc/ipsec.conf - Openswan IPsec configuration file
#
# Manual: ipsec.conf.5
#
# Please place your own config files in /etc/ipsec.d/ ending in .conf

version 2.0 # conforms to second version of ipsec.conf specification

# basic configuration
config setup
# Debug-logging controls: "none" for (almost) none, "all" for lots.
# klipsdebug=none
# plutodebug="control parsing"
# For Red Hat Enterprise Linux and Fedora, leave protostack=netkey
protostack=netkey
nat_traversal=yes
virtual_private=
oe=off
# Enable this if you see "failed to find any available worker"
# nhelpers=0

#You may put your configuration (.conf) file in the "/etc/ipsec.d/" and uncomment this.
include /etc/ipsec.d/*.conf


root#sudo vi /etc/ipsec.d/vpc1-to-vpc2.conf

conn vpc-to-asa
type=tunnel
authby=secret
left=%defaultroute
leftid=54.173.90.212  <Site A Public IP address>
leftnexthop=%defaultroute
leftsubnet=192.168.100.0/24  <Site A Private subnet>
right=52.74.103.204  <Site B Public IP address>
rightsubnet=200.3.2.0/24     <Site B Private subnet>
esp=aes192-sha1
keyexchange=ike
ike=aes192-sha1
salifetime=43200s
pfs=yes
auto=start
dpdaction=restart

root#sudo vi /etc/ipsec.d/vpc1-to-vpc2.secrets
54.173.90.212 52.74.103.204: PSK "q1w2e3r4t5y6u7i8o9p0zaxscdvfbgnh"

Ref: <Site A Public IP address> <Site B Public IP address>: PSK "Put a Preshared Key here!!"

root#sudo service ipsec start
root#sudo chkconfig ipsec on
root#sudo vi /etc/sysctl.conf
net.ipv4.ip_forward = 1

root#sudo service network restart

[root@ip-192-168-100-248 ~]# ping 200.3.2.221
PING 200.3.2.221 (200.3.2.221) 56(84) bytes of data.
64 bytes from 200.3.2.221: icmp_seq=1 ttl=64 time=230 ms
64 bytes from 200.3.2.221: icmp_seq=2 ttl=64 time=231 ms
64 bytes from 200.3.2.221: icmp_seq=3 ttl=64 time=231 ms


Site -B (Customer Side or Office end VPC)

root#sudo yum install openswan

root#sudo vi /etc/ipsec.conf
# /etc/ipsec.conf - Openswan IPsec configuration file
#
# Manual: ipsec.conf.5
#
# Please place your own config files in /etc/ipsec.d/ ending in .conf

version 2.0 # conforms to second version of ipsec.conf specification

# basic configuration
config setup
# Debug-logging controls: "none" for (almost) none, "all" for lots.
# klipsdebug=none
# plutodebug="control parsing"
# For Red Hat Enterprise Linux and Fedora, leave protostack=netkey
protostack=netkey
nat_traversal=yes
virtual_private=
oe=off
# Enable this if you see "failed to find any available worker"
# nhelpers=0

#You may put your configuration (.conf) file in the "/etc/ipsec.d/" and uncomment this.
include /etc/ipsec.d/*.conf

root#sudo vi /etc/ipsec.d/vpc1-to-vpc2.conf

conn vpc-to-asa
type=tunnel
authby=secret
left=%defaultroute
leftid=52.74.103.204  <Site B Public IP address>
leftnexthop=%defaultroute
leftsubnet=200.3.2.0/24   <Site B Private subnet>
right=54.173.90.212       <Site A Public IP address>
rightsubnet=192.168.100.0/24    <Site A Private subnet>
esp=aes192-sha1
keyexchange=ike
ike=aes192-sha1
salifetime=43200s
pfs=yes
auto=start
dpdaction=restart

root#sudo vi /etc/ipsec.d/vpc1-to-vpc2.secrets
52.74.103.204 54.173.90.212: PSK "q1w2e3r4t5y6u7i8o9p0zaxscdvfbgnh"

Ref: <Site A Public IP address> <Site B Public IP address>: PSK "Put a Preshared Key here!!"

root#sudo service ipsec start

root#sudo chkconfig ipsec on
192.168.100.248) 56(84) bytes of data.
64 bytes from 192.168.100.248: icmp_seq=1 ttl=64 time=231 ms
64 bytes from 192.168.100.248: icmp_seq=2 ttl=64 time=231 ms
64 bytes from 192.168.100.248: icmp_seq=3 ttl=64 time=231 ms


Reference:-

https://aws.amazon.com/articles/8800869755706543
http://houseoflinux.com/vpn/vpn-site-to-site-openswan-x-asa-cisco/page-2
https://techlib.barracuda.com/bfw/configamazonvpngateway

14 comments:

  1. This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses. vpn reviews

    ReplyDelete
  2. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. vpn services

    ReplyDelete
  3. Online entertainment is not just fun but also profitable. great roulette online game The best online casinos at your service.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Hi, thank you very much for new information , i learned something new. Very well written. It was so good to read and usefull to improve knowledge. Keep posting. If you are looking for any python related information please visit our website
    python training in bangalore

    ReplyDelete

Gitlab Automation Project Showcase

My GitLab Projects Showcase 🚀 Welcome to my portfolio of GitLab projects. Each repository reflects my journey as an engineer, focusing...