* POST UPDATED: 24-02-2016 @ 09:12AM
How to run CHR on AWS (Amazon Web Services) VPC (Virtual Private Cloud) as the default firewall / router gateway
Many people have been asking me how to use the CHR as the default firewall / router of your VMs behind a VPC in AWS. Here is a guide that will guide you step by step.
Is not as hard as it seems.
Basic concepts:
What is AWS?
https://aws.amazon.com/
What is an EC2?
https://aws.amazon.com/ec2/
What is a VPC?
https://aws.amazon.com/vpc/
Considerations
- You have to define different LAN/WAN segments for your CHR and for your VMs behind the CHR
- Your LAN segment on the CHR will be different from your LAN segment on your VMs. AWS will route then for you
- The VPC will control the routes between your networks
Network layout:
Steps:
1.
Create a VPC using the wizard. Choose "VPC with Public and Private Subnets"
* LAN for VMs: 10.10.21.0/24 (LAN1)
* LAN for CHR: 10.10.11.0/24 (LAN2)
2. Once done you will need to
delete the NAT gateway or NAT instance automatically created by the wizard. The CHR will replace this NAT instance.
3. Now you need to
create another subnet that will connect the CHR to the internet
* WAN for CHR: 10.10.12.0/24 (WAN)
4. At the VPC subnets menu you have to
change the route table assigned to the new subnet. You have to choose the NOT main table where target for 0.0.0.0/0 will be something like this "igw-c064bfa4"
5.
Create you CHR VM based on AMI (image)
* Assign and IP from WAN network
* Create and assign a security profile with full access (because the CHR will be your firewall)
6. Once created you have to disable "Source/Destination Check" to allow the CHR to be the gateway of your VMs
7.
Create and assign an elastic IP for you CHR
* Now you can access your CHR from internet
* Highly recommended: change default password of the CHR
* Check that you can access the CHR, then shutdown the VM
* UPDATED: 24-02-2016 @ 09:12AM
8.
Create a new network interface and assign it to the CHR
* Assign and IP from LAN2 (this will be used to reach your VMs)
*
Also disable "Source/Destination Check" on this new interface (check step 6)
* UPDATED: 24-02-2016 @ 09:12AM
9. VPC main routing table:
you have to change the VPC main routing table to allow you CHR to be the default gateway of your VMs. To do that you have to:
* Modify the main routing table selecting your CHR VM as gateway for destination 0.0.0.0/0
10.
Start your CHR VM
* Access it using winbox or webfig (use elastix IP)
11.
Add a DHCP client on the ether2 (subnet to access LAN servers) without default route
12.
Add a static route to reach the LAN segment
13.
Create and start a new VM and assign to your LAN1 segment (10.10.21.0/24)
* Assign a security profile with full access (because the CHR will be your firewall)
14.
Once started you should ping it from your CHR
15.
Create the appropriate masquerade rule and a dst-nat to access your VM.
16.
Finally access your VM from the public IP
17.
Configuring your CHR as firewall, vpn server, etc
18.
You can access the actual example CHR to see the configuration (use winbox):
IP: 52.72.63.46
User: mikrotik
Password: mikrotik
Group: read
* UPDATED: 24-02-2016 @ 09:12AM
19. Access the web server behind the CHR
* To check that is working you can access via web browser to
http://52.72.63.46:380/
* There is a dst-nat to access the web server on the Ubuntu server behind the CHR