Configuring the VPC and VPC Flow Logs for an AWS Site to Site pfSense VPN
ACM.465 Creating a VPC to connect our pfSense to via a VPN and configuring logging to inspect the related network traffic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⚙️ Check out my series on Automating Cybersecurity Metrics. The Code.
🔒 Related Stories: Network Security | AWS Security | Cloud Architecture
💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the last post I explained why you might want to route your traffic through AWS.
In this post I’m going to set up the VPC and VPC flow logs manually for use in that architecture.
If you want to automate creation of a VPC and Flow Logs and add some governance to ensure they are always set up correctly I wrote about that in other posts:
Create a VPC (AWS Virtual Private Cloud)
Head over to the VPC Dashboard in AWS.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*F-Blk8QAoWtwvpz1cG-FxA.png)
You’ll see a default VPC there but we’re going to create a separate VPC for this process.
Click Create VPC.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*OixecCeCTfTYTclIljJNHQ.png)
Add the VPC settings:
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*6yHDKXo7KNX_G0WVXiXQng.png)
Click Create VPC.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*OuTeUxfFLTcZ0WNlx5yeHw.png)
Inspect the VPC Routes
Why did I create a separate VPC instead of using the default?
Look at the route table for your new VPC:
Click next to your VPC, then click on the route table link. (It might take a minute to show up.)
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*mx_Rr5RZwavzz9ZVOWeR8g.png)
Click on Routes.
This route table only has a local route, meaning anything deployed in this VPC cannot reach (or be attacked by) something on the Internet.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*4vWON1A4DOVfNtDaRigVJw.png)
Head back to your list of VPCs and click on the default VPC that was in your account when you created it.
The default VPC in your account has an Internet Gateway route by default. That means traffic can get directly to the Internet. You could remove it but I’d rather just create a new VPC instead and maintain more control over the route tables. Also, when you try to automate you can import that VPC but it may be easier to create a new one. Also some tools look for and use the default VPC and I want to make sure this VPC I’m creating is not used for anything except the purpose for which I am creating it.
Configure VPC Flow Logs for your new VPC
Head back over to the VPC list and click on your new VPC, then Flow Logs.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*1P_rRBqM7E1V29XK_4q55w.png)
Because I’m not going to send a lot of traffic to AWS I’m going to go ahead and select a 1 minute interval to see traffic more real time. The traffic will show up either based on a time interval or the amount of data in the logs — see the AWS Flow Logs documentation for details.
Also, we need to create a role for VPC Flow Logs and I’m going to send my logs to CloudWatch, which requires a log group. See the next steps.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*x1ob0B-V-x5OhC8SGMvn1w.png)
I like to open a new window so I don’t lose what I was doing.
Click on the AWS window and choose open in a new tab.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*QRe_67_vV75LYNPgp4KiDw.png)
Create a CloudWatch Log Group
CloudWatch is the service where you can store AWS logs of almost any kind.
Although AWS doesn’t specifically have a SIEM solution, this is a log repository where you can store all your logs and create any sort of automation you want based on those logs. I wrote about how to do that in a white paper for SANS nearly a decade ago now in a white paper entitled Balancing Security and Event Driven Automation.
Larger companies and organizations may want to explore Security Data Lake:
Some companies opt to store logs in S3 to save money but then you have to have the tools to query the data the way you need and to keep those buckets secure.
CloudWatch will work well for this small test and it works well for most of the things I do. You can check out the pricing here:
Head over to the CloudWatch dashboard.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*tkzPb_3qI679-bDFJj6QWg.png)
Expand Logs. Click on Log groups. Click Create log group.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*pjK1C1-ZOXT3ioMiNu-gZw.png)
For my long term solution I’d want to create a KMS key but this is a short test. I’m also going to set the retention setting for the logs to 30 days. As logs accumulate you will pay for storage so you have to balance how long you may need them for a security incident versus the cost of retaining those logs.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*ITXgZALu6rLsacsAB0b76A.png)
More on KMS Keys to encrypt your data here:
Click Create.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*-Usuy8Dj55pwhLPt83tNjA.png)
Create an AWS IAM Role
Right click on the AWS Logo again and right click to open a new tab.
Head over to the AWS IAM dashboard.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*KuH47rQWiFIIpU8MQMfVPw.png)
Click on Roles and Create Role.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*MuKEezw2qCgLu6SakHJfjg.png)
I’m going to create the role described in this documentation — and I don’t see a good way to do that other than to create it manually. This used to be easier and I don’t know why AWS changed it.
Choose Custom trust policy. Copy and paste the role trust policy from the documentation. We could add some additional restrictions here using conditions to limit this role further which I wish AWS would add to their documentation. I also wish they would limit the documentation for this to one page as there are multiple sources with this same information. But for now I have this:
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*Fu7iLF-fuUZipnNingMWEw.png)
Click Next.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*8zWpb2reBeoTYygQOAOi1Q.png)
Sadly, AWS does not offer a managed policy for Flow Logs:
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*LYpPd_K-3F6bBlTbFhoWfQ.png)
So we’ll need to create a new policy. Once again, I right click on the AWS logo and choose to open the link in a new tab.
Head over to the IAM dashboard.
Click Policies and Create Policy.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*fV6JApcBzwZPp75S5PoY7g.png)
Click JSON. Copy and paste the policy from the documentation.
Note that this policy could be better. It could restrict this role to operate only on the Flow Logs group and only in this specific account and so on as I’ve mentioned in other posts on IAM.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*tR1axBpOKO1g5md2B9bZHw.png)
Click Next:
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*cXBcseyE9ZvSpjJinAFcfw.png)
Give your policy a name.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*u2AzXZLbSDPHIwMuGY10FA.png)
Create the policy.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*phlYLYJCn2G-xtZI_3O_nA.png)
Return to the tab where we were creating the role.
Click the refresh button.
Select the role you just created and click Next.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*Gd8vDUV-zub8JpH8SYcUGg.png)
Give your role a name.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*Z81R7i_fPHRWE088Uvduvg.png)
Choose Create Role.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*X3-zngkb0acQUfXum0jmCw.png)
Also be aware of who else can modify your logs and create policies that govern your logs appropriately.
Complete the VPC Flow Logs Configuration
Click the two refresh buttons and the items you just created will appear in the list when you click the text boxes for your log group and IAM role. You can now select them.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*EKAkW0BA8GOkKbp67Pk9tQ.png)
Click Create Flow Log.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*XkpaCpXQtimjbSJk8_F0rw.png)
Head back over to your VPC. Click on it. Click on Flow logs. Verify that you see your new flow logs entry.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*ZipLu2Mh4O5qyiBzOKTZ8g.png)
You can click on the flow log link on the right to see the log group where your logs will end up. Right now it’s empty because there’s no traffic flowing in our VPC.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*4zrcQBHaYG0KzdqVfzV5wg.png)
If you follow along in this mini-series on sending traffic from a pfSense through AWS to the Internet, you’re going to end up with the following logs in this log group:
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*nIVxPSjB7YEmp3DKWYAUfQ.png)
The logs will have different formats.
- The ENIs will have VPC Flow Logs.
- The Transit Gateway logs show traffic flowing through the gateway.
- The VPN logs show the IKE connection information.
I’ll show you those logs in a separate post.
Now we have a VPC and Flow Logs set up to send traffic logs to CloudWatch. Next I’m going to create my subnets.
Follow for updates.
Teri Radichel | © 2nd Sight Lab 2024
About Teri Radichel:
~~~~~~~~~~~~~~~~~~~~
⭐️ Author: Cybersecurity Books
⭐️ Presentations: Presentations by Teri Radichel
⭐️ Recognition: SANS Award, AWS Security Hero, IANS Faculty
⭐️ Certifications: SANS ~ GSE 240
⭐️ Education: BA Business, Master of Software Engineering, Master of Infosec
⭐️ Company: Penetration Tests, Assessments, Phone Consulting ~ 2nd Sight Lab
Need Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for Presentation
Follow for more stories like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
❤️ Sign Up my Medium Email List
❤️ Twitter: @teriradichel
❤️ LinkedIn: https://www.linkedin.com/in/teriradichel
❤️ Mastodon: @teriradichel@infosec.exchange
❤️ Facebook: 2nd Sight Lab
❤️ YouTube: @2ndsightlab
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*H9Ew1KCl-29nZiPR.jpeg)