AWS-设置站点到站点VPN连接



[Hi All, those interested in understanding AWS Networking in depth may want to enroll for this Udemy course.
https://www.udemy.com/course/networking-in-aws/?referralCode=6F9B5997DA10F80BE734
]

您可以在此处下载VPN设置文档:https://awstrainingcenter-test.s3-us-west-2.amazonaws.com/10+-+Setup+Site+to+Site+VPN+Connection+in+AWS.pdf

了解如何在AWS中设置站点到站点VPN连接。在这里,我们将使用另一个地区的AWS VPC模拟网络的客户端。

有用的信息:

1.安装Openswan的帮助/命令
    一世。更改为root用户:
                $ sudo su
    ii。安装openswan:
                $ yum install openswan -y
    iii。在/etc/ipsec.conf中,如果还没有注释,请取消注释
          未评论:
                 包括/etc/ipsec.d/*.conf
    iv。更新/etc/sysctl.conf具有以下内容
        net.ipv4.ip_forward = 1
 net.ipv4.conf.all.accept_redirects = 0
 net.ipv4.conf.all.send_redirects = 0
    v。重新启动网络服务:
                 $服务网络重启

2. /etc/ipsec.d/aws-vpn.conf的内容
康恩隧道1
        authby =秘密
        自动=开始
        左=%defaultroute
        leftid =客户端VPN公用IP
        right = AWS VPN隧道1公用IP
        类型=隧道
        ikelifetime = 8h
        keylife = 1h
        phase2alg = aes128-sha1; modp1024
        ike = aes128-sha1; modp1024
        按键次数=%永远
        keyexchange = ike
        leftsubnet =客户端VPN CIDR
        rightsubnet = AWS结束VPN CIDR
        dpddelay = 10
        dpdtimeout = 30
        dpdaction = restart_by_peer

3. /etc/ipsec.d/aws-vpn.secrets的内容
customer_public_ip aws_vgw_public_ip:PSK“共享机密”

4.启用/启动ipsec服务的命令
           $ chkconfig ipsec开启
           $ service ipsec start
           $ service ipsec状态。

36 comments
  1. Hi

    I know this question has been asked by
    @Noam Lerner but your explanation seems a bit hazy for me to understand. This is regarding creating a Customer Gateway. Is the Customer Gateway an AWS component or a plain router at a Data center? From AWS documentation, it appears that the Customer Gateway is something that need setting up at a Data center which implies this is a router – But then why does AWS provide a component / resource called 'Customer Gateway'? Is the documentation incorrect? Also, is OpenSwan mandatory to be set up – is that acting as a router which you are mentioning at 14:00. If yes, do we require a 'Customer Gateway'? From your tutorial, I am assuming no matter what, a VPN connection always require creating a Customer Gateway on AWS side (when we already have a router in Data center) – pretty confusing when referring to AWS documentation – could you help clarify this?

  2. I followed the whole steps but tunnel is not up after i start the ipsec service. The logs says :
    ov 21 07:18:02 s2svpntest pluto[16098]: "Tunnel1" #22: STATE_MAIN_I1: retransmission; will wait 2 seconds for response

    Nov 21 07:18:04 s2svpntest pluto[16098]: "Tunnel1" #22: STATE_MAIN_I1: retransmission; will wait 4 seconds for
    Nov 21 07:18:32 s2svpntest pluto[16098]: "Tunnel1" #22: STATE_MAIN_I1: retransmission; will wait 32 seconds for response

    Main PID: 16632 (pluto)

    Status: "Startup completed."

    CGroup: /system.slice/ipsec.service

    └─16632 /usr/libexec/ipsec/pluto –leak-detective –config /etc/ipsec.conf –nofork

    Nov 21 07:26:59 s2svpntest systemd[1]: Stopped Internet Key Exchange (IKE) Protocol Daemon for IPsec.

    Nov 21 07:26:59 s2svpntest systemd[1]: Starting Internet Key Exchange (IKE) Protocol Daemon for IPsec…

    Nov 21 07:27:00 s2svpntest ipsec[16620]: nflog ipsec capture disabled

    Nov 21 07:27:00 s2svpntest systemd[1]: Started Internet Key Exchange (IKE) Protocol Daemon for IPsec.

    Any idea how to fix it? Can you please provide your email id to examplesbdev@gmail.com

  3. How can I use this to access private instances directly from my machine? I do not want to use Bastion host, I want to access the instances directly using their private IPs. My device is a personal laptop, and hence is not under a company's network or a firewall. Any recommendations? Thanks a lot!

  4. Thanks for the great tutorial, now the VPN connection is configured through my another EC2 instance in different region. Can you please help me out how can i use the public IP address of CGW to access my private EC2 instance from browser?

  5. Hi
    I am getting no pre-shared key found for local-ip remote-ip, I have followed exact steps to configure, can you please help?
    " #520: sending notification NO_PROPOSAL_CHOSEN to 52.62.224.198:500

    Sep 27 06:46:43 ip-10-200-0-136.eu-west-1.compute.internal pluto[4427]: "Tunnel1 " #520: Can't authenticate: no preshared key found for `63.32.62.61' and `52.62. 224.198'. Attribute OAKLEY_AUTHENTICATION_METHOD

  6. Thanks for making the video!
    I'm wondering why didn't you put the customer gateway in VPC-B. Looking at the AWS documentation[1], seems like that's what they recommend.
    I'm probably missing something – as your video shows that the VPN is up, so I thought to ask.
    Also, let's say I'd like to setup the second tunnel as well – would that be done in a similar way?

    Thanks!

    [1] https://docs.aws.amazon.com/vpn/latest/s2svpn/Examples.html

  7. If you follow the video then you can complete this practical, give your hundred percent and do not give up then you can complete this exercise. Good video and this practical made me more confident.

  8. Again completed AWS VPN site to site practical successfully just follow the instructions and I am sure everyone would be able to complete it.Thanks Sir.

  9. I have completed the practical and IPSEC service started successfully and I am able to ping private IP address of EC2 under VPC-A.Thanks

  10. unable to start IPSEC service again , I don't know where i am making a mistake .when i type journalctl -xe
    it shows error message as Sep 01 20:13:23 ip-10-200-0-102.us-west-1.compute.internal systemd[1]: Failed to start Internet Key Exchange (IKE) Protocol Daemon for IPsec.

    — Subject: Unit ipsec.service has failed

    — Defined-By: systemd

  11. Awesome video as always…….. ?
    But can you kindly explain the reason for disabling the source and destination check on ec2 instance at the vpc B (i.e. customer assumed network)

  12. Aug 27 20:12:28 ip-10-200-0-148.ap-south-1.compute.internal pluto[3460]: "Tunnel1" #5: Can't authenticate: no preshared key found for `13.233.97.136' and `3.1…_METHOD

    Aug 27 20:12:28 ip-10-200-0-148.ap-south-1.compute.internal pluto[3460]: "Tunnel1" #5: no acceptable Oakley Transform

    I am receiving above message when I type service ipsec status, kindly help

  13. This is very nice and helpful. Thanks for making such videos. I am able to setup VPN following the same steps and able to ping from both the sides, like from AWS EC2 private instance to Openswan and vice versa. But I have made another EC2 instance in Openswan side and unable to reach that from other side of the VPN neither able to reach any ec2 instance in other side from that instance. Actually that is the purpose of Site-to-site VPN, can you please help how to achieve that with openswan.

  14. Very thanks for the session. I have followed each and every step keenly. At the last minute i have got a error when i typed the command service ipsec start as"Job for ipsec.service failed because the control process exited with error code. See "systemctl status ipsec.service" and "journalctl -xe" for details" Kindly help me to overcome

  15. I am unable to start ipsec serice and receiving error message as "Redirecting to /bin/systemctl start ipsec.service
    Job for ipsec.service failed because the control process exited with error code. See "systemctl status ipsec.service" and "journalctl -xe" for details" what to do

  16. Hi Team,

    I tried this complete lab. Thanks first of all for such a detailed video. But I am stuck on last step. My ipsec service is failing any solution.

    Aug 01 11:10:04 ip-10-200-0-212.ec2.internal systemd[1]: ipsec.service failed.
    [root@ip-10-200-0-212 ec2-user]# service ipsec status
    Redirecting to /bin/systemctl status ipsec.service
    ● ipsec.service – Internet Key Exchange (IKE) Protocol Daemon for IPsec
    Loaded: loaded (/usr/lib/systemd/system/ipsec.service; enabled; vendor preset: disabled)
    Active: failed (Result: start-limit) since Thu 2019-08-01 11:10:04 UTC; 5min ago
    Docs: man:ipsec(8)
    man:pluto(8)
    man:ipsec.conf(5)

    Aug 01 11:10:04 ip-10-200-0-212.ec2.internal systemd[1]: ipsec.service: control process exited, code=exited status=3
    Aug 01 11:10:04 ip-10-200-0-212.ec2.internal systemd[1]: Failed to start Internet Key Exchange (IKE) Protocol Daemon for IPsec.
    Aug 01 11:10:04 ip-10-200-0-212.ec2.internal systemd[1]: Unit ipsec.service entered failed state.
    Aug 01 11:10:04 ip-10-200-0-212.ec2.internal systemd[1]: ipsec.service failed.
    Aug 01 11:10:04 ip-10-200-0-212.ec2.internal systemd[1]: ipsec.service holdoff time over, scheduling restart.
    Aug 01 11:10:04 ip-10-200-0-212.ec2.internal systemd[1]: start request repeated too quickly for ipsec.service
    Aug 01 11:10:04 ip-10-200-0-212.ec2.internal systemd[1]: Failed to start Internet Key Exchange (IKE) Protocol Daemon for IPsec.
    Aug 01 11:10:04 ip-10-200-0-212.ec2.internal systemd[1]: Unit ipsec.service entered failed state.
    Aug 01 11:10:04 ip-10-200-0-212.ec2.internal systemd[1]: ipsec.service faile

Comments are closed.