{"id":235533,"date":"2017-04-10T10:58:02","date_gmt":"2017-04-10T14:58:02","guid":{"rendered":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/?p=235533"},"modified":"2017-04-10T11:34:14","modified_gmt":"2017-04-10T15:34:14","slug":"the-voip-addicts-guide-redundancy-in-the-cloud-openswan-vpn","status":"publish","type":"post","link":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/the-voip-addicts-guide-redundancy-in-the-cloud-openswan-vpn\/","title":{"rendered":"The VoIP Addict&#8217;s Guide &#8211; Redundancy in the Cloud: OpenSwan VPN"},"content":{"rendered":"<p>A few weeks ago, I wrote about redundancy in the cloud, mainly using AWS (Amazon Web Services) as an example.<\/p>\n<p>Today, we&#8217;ll talk about how to connect multiple regions together through a VPN so that systems can synchronize local IP address to local IP address. Some systems will allow you to send backups and perform a restore over the Internet to public IP addresses, but in the event, you are using one that doesn&#8217;t, a VPN will be required. Connecting different regions together is important because sometimes entire regions on a cloud platform can suffer from catastrophic\u00a0failures as recent events will prove. Placing all of your eggs in one basket, as they say, is a bad idea. Unfortunately, when it comes to AWS, there is no mechanism to route traffic to a geographically separated region over AWS alone. I have no idea why, but that&#8217;s just the rules the AWS gods have directed us to follow. So, to fix that, we need to create a VPN.<\/p>\n<p>Fortunately, there all sorts of canned VPN solutions. The downside is: they generally cost quite a bit of money. You&#8217;ll find that you will need to pay a subscription fee on top of AWS usage charges for a Palo Alto, Brocade, or Fortinet virtual appliance. While these are great to have, they might be cost or operationally prohibitive for your environment.<\/p>\n<p>Thankfully, there is another solution, and it&#8217;s called OpenSwan. <a href=\"https:\/\/www.openswan.org\/\">OpenSwan is a quick and easy way to turn a Linux machine into a VPN server using IPSec.<\/a> The major benefits are that it&#8217;s free to use and install, and it can run on a cheap instance on AWS (free tier). Meaning, you&#8217;ll essentially just pay for storage, which can be small at 8 Gigs per machine. You&#8217;ll, of course, need two of these Linux instances, one per region. Let&#8217;s create a hypothetical scenario, configure a VPN between two AWS regions, and route traffic appropriately.<\/p>\n<p>Imagine an East and West region with non-overlapping IP addresses in their respective VPCs (virtual private cloud). If you&#8217;re not familiar with AWS, the VPC is the top hierarchical unit which contains subnets. Within the subnets are your instances. In our example, the West VPC uses 10.0.0.0\/16, with a single 10.0.0.0\/24 subnet configured, giving you 254 hosts minus a few that AWS uses for the Internet gateway and DNS. The East region uses 172.16.0.0\/16, with 172.16.0.0\/24 carved out of it, which also allows 254 hosts minus a handful. In each region, there will be an IP PBX, and OpenSwan server. The West is designated as the primary site for phones to register to, and <a href=\"\/blog\/voip-insider\/the-voip-addicts-guide-voip-redundancy-in-the-cloud\/\" onclick=\"ga('send', 'event', 'voip-insider-blog-post', 'click', 'the East as the warm ');\">the East as the warm spare as described in my last post.<\/a> In the specific case of <a href=\"https:\/\/www.freepbx.org\/\">FreePBX<\/a>, the warm IP PBX will perform a backup of the primary via the VPN, \u00a0save the configuration locally, and restore it so it becomes an identical copy with the exception of network settings. In the <a href=\"http:\/\/wazo.community\/\">case of <\/a>Wazo, the VPN would be used for more frequent synchronizations along with a ping probe to monitor availability. The figure below depicts our scenario (please excuse the Visio drawing):<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235543\" src=\"\/blog\/voip-insider\/files\/2017\/04\/VPN-scenario-image.png\" alt=\"vpn-scenario-image\" width=\"726\" height=\"596\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/VPN-scenario-image.png 726w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/VPN-scenario-image-150x123.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/VPN-scenario-image-300x246.png 300w\" sizes=\"auto, (max-width: 726px) 100vw, 726px\" \/><\/p>\n<p>Let&#8217;s build our VPN (IPSec with PSK).<\/p>\n<p><em>Somme AWS and Linux experience required.<\/em><\/p>\n<ol>\n<li>Launch two new instances of Amazon Linux in the FreeTier (t2.micro). The VPN is meant for synchronization only, so it doesn&#8217;t need a lot of horsepower or network performance.<img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235553\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step1.png\" alt=\"step1\" width=\"681\" height=\"58\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step1.png 681w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step1-150x13.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step1-300x26.png 300w\" sizes=\"auto, (max-width: 681px) 100vw, 681px\" \/><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-235563 aligncenter\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step-1-2.png\" alt=\"step-1-2\" width=\"691\" height=\"214\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step-1-2.png 691w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step-1-2-150x46.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step-1-2-300x93.png 300w\" sizes=\"auto, (max-width: 691px) 100vw, 691px\" \/><\/p>\n<p>2. Attach Elastic IP addresses to your instances.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235573\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step2.png\" alt=\"step2\" width=\"700\" height=\"69\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step2.png 700w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step2-150x15.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step2-300x30.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>3. Route traffic for the opposite region to your new instances.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235583\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step3.png\" alt=\"step3\" width=\"689\" height=\"583\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step3.png 689w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step3-150x127.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step3-300x254.png 300w\" sizes=\"auto, (max-width: 689px) 100vw, 689px\" \/><\/p>\n<p>4. In the security groups for each OpenSwan server, allow the Elastic IP address of the opposite server. You will also need to allow the opposite subnets in the security groups of the IP PBXs. Below are catch-all rules:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235593\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step4.png\" alt=\"step4\" width=\"703\" height=\"438\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step4.png 703w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step4-150x93.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step4-300x187.png 300w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/p>\n<p>5. Log into your instance update, and install OpenSwan on each.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235603\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step5.png\" alt=\"step5\" width=\"700\" height=\"91\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step5.png 700w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step5-150x20.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step5-300x39.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>6. Uncomment (remove the&#8217;#&#8217;) the last line in \/etc\/ipsec.conf to include *.conf files in \/etc\/ipsec.d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235613\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step6.png\" alt=\"step6\" width=\"692\" height=\"53\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step6.png 692w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step6-150x11.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step6-300x23.png 300w\" sizes=\"auto, (max-width: 692px) 100vw, 692px\" \/>7. In \/etc\/sysctl.conf, modify net.ipv4.ip_forward to equal 1, and add:<\/p>\n<p>net.ipv4.conf.all.accept_redirects=0<\/p>\n<p>net.ipv4.conf.all.send_redirects=0<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235623\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step7.png\" alt=\"step7\" width=\"698\" height=\"52\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step7.png 698w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step7-150x11.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step7-300x22.png 300w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/p>\n<p>8. Create the configuration for the West region OpenSwan instance.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235633\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step8.png\" alt=\"step8\" width=\"697\" height=\"309\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step8.png 697w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step8-150x66.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step8-300x133.png 300w\" sizes=\"auto, (max-width: 697px) 100vw, 697px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>9. Create a .secrets file for the West region OpenSwan instance.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235653\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step9.png\" alt=\"step9\" width=\"694\" height=\"94\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step9.png 694w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step9-150x20.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step9-300x41.png 300w\" sizes=\"auto, (max-width: 694px) 100vw, 694px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>10. Do the same on the East OpenSwan instance.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235663\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step10.png\" alt=\"step10\" width=\"698\" height=\"294\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step10.png 698w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step10-150x63.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step10-300x126.png 300w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235643\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step8-2.png\" alt=\"step8-2\" width=\"699\" height=\"93\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step8-2.png 699w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step8-2-150x20.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step8-2-300x40.png 300w\" sizes=\"auto, (max-width: 699px) 100vw, 699px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>11. Restart the network service on each server and start the VPN.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235673\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step11.png\" alt=\"step11\" width=\"706\" height=\"100\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step11.png 706w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step11-150x21.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step11-300x42.png 300w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><\/p>\n<p>12. Check your VPN status.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-235683\" src=\"\/blog\/voip-insider\/files\/2017\/04\/step12.png\" alt=\"step12\" width=\"693\" height=\"90\" srcset=\"https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step12.png 693w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step12-150x19.png 150w, https:\/\/www.voipsupply.com\/blog\/voip-insider\/files\/2017\/04\/step12-300x39.png 300w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><\/p>\n<p>Verify connectivity by pinging each opposing OpenSwan&#8217;s internal IP address and also the IP addresses of the IP PBXs. You&#8217;ll also want to make sure each IP PBX can communicate across the VPN as well. If you are modifying these configurations to fit your own specific setup and the VPN fails, check to make sure all of your IP addresses are correct and that your security groups are allowing the traffic. After any corrections are made, be sure to restart ipsec by using &#8216;service ipsec restart.&#8217;<\/p>\n<p>If all went well, you now have the ability to synchronize or replicate your IP PBX configuration. I&#8217;d like to add and make clear that the scenario and configuration above should strictly be considered a proof of concept and shouldn&#8217;t be used for production. If you are thinking of employing a similar setup, make sure you are more specific with your security groups (mostly with allow protocols, and outbound connections). You should also consider narrowing your subnets to something significantly smaller if you won&#8217;t be needing so many IP addresses. There are also several ways to configure OpenSwan. I chose PSK in this example because it is the most simple to configure, <a href=\"https:\/\/github.com\/xelerance\/Openswan\/wiki\">but check out the OpenSwan wiki for more options<\/a>.<\/p>\n<p>Thanks for reading and Happy VoIPing!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few weeks ago, I wrote about redundancy in the cloud, mainly using AWS (Amazon Web Services) as an example. Today, we&#8217;ll talk about how to connect multiple regions together through a VPN so that systems can synchronize local IP address to local IP address. Some systems will allow you to send backups and perform [&hellip;]<\/p>\n","protected":false},"author":233,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1221,1222,1223],"tags":[],"class_list":["post-235533","post","type-post","status-publish","format-standard","hentry","category-small-business-voip","category-technical-advice","category-voip-systems"],"_links":{"self":[{"href":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/wp-json\/wp\/v2\/posts\/235533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/wp-json\/wp\/v2\/users\/233"}],"replies":[{"embeddable":true,"href":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/wp-json\/wp\/v2\/comments?post=235533"}],"version-history":[{"count":10,"href":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/wp-json\/wp\/v2\/posts\/235533\/revisions"}],"predecessor-version":[{"id":235783,"href":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/wp-json\/wp\/v2\/posts\/235533\/revisions\/235783"}],"wp:attachment":[{"href":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/wp-json\/wp\/v2\/media?parent=235533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/wp-json\/wp\/v2\/categories?post=235533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.voipsupply.com\/blog\/voip-insider\/wp-json\/wp\/v2\/tags?post=235533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}