Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Create an AWS Remote Access VPN Gateway with WireGuard and Netmaker

Sign upSign InSign upSign InAlex FeiszliFollowITNEXT--ListenShareAn AWS account typically consists of multiple VPC’s and private subnets. You may wish to provide remote access to private subnets or endpoints on AWS without exposing them publicly.AWS has their own remote access VPN solution called “AWS Client VPN”. However, this can be unnecessarily expensive. With several users and endpoints, you can easily spend hundreds of dollars per month.Luckily, it is pretty easy to build your own solution using WireGuard® and Netmaker for free. Follow these steps, and you should be up and running in about 30 minutes.By the end of this tutorial, you will have a gateway device running on AWS, on which you can easily attach WireGuard clients to access private AWS resources.In our example scenario, we have Rocket Chat running on AWS, which is only accessible over the VPC address (172.31.95.26). We want a developer to be able to log into Rocket Chat using this address.For your setup, this can be any private IPs or subnets on AWS, as long as the addresses are accessible from the gateway device (EC2 instance).Select a device in AWS to act as your VPN gateway. This can be a container or EC2 instance, but must be linux-based. You can use an existing instance, but if deploying a new instance, we recommend using the latest Ubuntu (22.04 as of this writing). You can use t2.micro, as it is not resource intensive.This device must have access to the target devices or subnets, so make sure it is deployed in the correct availability zone, and that the target devices’ security settings allow traffic from the gateway device.Lastly, the device must be accessible publicly over the WireGuard port, which by default for Netmaker is 51821, so open 51821/udp to 0.0.0.0/0 in the Security settings, and make sure it has a publicly reachable IP (e.g. Elastic IP address).Gateway Requirements:- Device Type: EC2 Instance or Container (EC2 Instance recommended)- OS: Linux (Ubuntu 22.04 recommended)- Size: any (t2.micro recommended) - Network Settings: Must have a public endpoint, and expose 51821/udp publiclyNow that you’ve configured a suitable gateway device, you must add this device to Netmaker. You can self-host Netmaker, but to get started quickly (and for free), simply sign up at https://app.netmaker.io.By default, your account will have a virtual network named “netmaker” and an access key, also named “netmaker”. You should use these for the remainder of the tutorial, but note that in our example and screenshots these are named “rocket-chat”.Click on the network, click on “hosts”, and then click the “Add a new host” button:Follow the steps to add the gateway device to Netmaker, by downloading and installing the netclient, and joining the network.Once the device is visible in your “hosts” lists, you can continue to configure the device as a Gateway.Click on “Egress” and then “Create Egress”. We will set the gateway device as an egress to the target IP address in AWS. In our example this is 172.31.95.26/32, but modify this as appropriate, providing multiple ranges if necessary.The device is now prepared to serve traffic to the target destination.The last step is to provide remote access via a “Client Gateway”. The Client Gateway simply allows you to generate WireGuard config files, which are routed through the gateway device and into the network. So, after configuring, a user will be able to reach the Egress range via the Client Gateway.Our device on AWS will act as both an “Egress Gateway” and a “Client Gateway”, so that it can accept traffic from WireGuard, and forward it to the private subnet.Click on “Clients” and then “Create Client”. Since you do not have a Client Gateway yet, it will prompt you to select a device to act as the gateway, and will generate your first client (WireGuard config file) on top of this gateway.You can now download this config file, and run it using any standard WireGuard client.If everything has gone correctly, the private address should now be accessible from the local device:You can generate additional clients as necessary, so that your gateway provides access for a whole team.In this tutorial, we:There is much more you can do with Netmaker and WireGuard, so I hope this was a good first experience. The above steps are also available as a click-through tutorial at the following link: https://www.netmaker.io/tutorials#remote-access-gatewayIf you have any questions or feedback, let me know in the comments!----ITNEXTAlex is CEO of Netmaker (https://netmaker.io), a cloud networking company building the next-gen virtual networking platform.Alex Feiszliinnetmaker--5Juntao QiuinITNEXT--7Daniel GlejznerinITNEXT--11Alex FeiszliinITNEXT--1DmitinAWS in Plain English--Hovhannes Mikayelyan--DeveloperSteveinCloud Native Daily--1headinthecloudsinAWS Tip--2Thilina Ashen GamageinPlatform Engineer--2Ali MoezziinLevel Up Coding--HelpStatusWritersBlogCareersPrivacyTermsAboutText to speechTeams



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

Create an AWS Remote Access VPN Gateway with WireGuard and Netmaker

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×