For the longest time I was under the assumption a router in an AWS VPC could only have one NIC. Writing IPtables/firewall rules for one interface can be tedious!!! However, I have discovered how to setup OPSense in an AWS VPC with multiple NICs. That is right, you will have a WAN NIC(public subnet) and a NIC for each private subnet.
Create AWS VPC
- Login into AWS console
- Select “VPC” from the list of AWS services
- Select “Elastic IPs” on the left
- Select “Allocate new address” and select “Allocate”
- Select “VPC Dashboard” in top left
- Select “Start VPC wizard”
- Select” VPC with Public and Private subnets” for VPC configuration
- VPC with public and private subnets
- Enter “172.21.0.0/16” for IPv4 CIDR block
- Select “No IPv6 CIDR block” for IPv6 CIDR block
- Enter a name for VPC name
- Enter “172.21.100.0/24” for public subnet IPv4 CIDR
- Select a an AWS region for availability zone
- Enter “<VPC name from above>_public_subnet”
- Enter “172.21.101.0/24” for private subnet IPv4 CIDR
- Select same AWS region as above
- Enter “<VPC name from above>_private_subnet”
- Select elastic IP from above
- Select “Create VPC”
- This will take about 5-10mins so be patient
Create AWS OPNsense instance
Create instance
- Select “EC2” from AWS services
- Select “Launch instance”
- Select “Community AMIs” on the left
- Enter “opnsense” into search
- Select “OPNsense-20150708.beta3″
- Select “t2.small” for instance type
- Configuration instance details
- Select “test” VPC for network
- Select “test_public_subnet” for subnet
- Network interface
- Enter “172.21.100.254” for primary IP address under “Network interfaces”
- Select “Add device” under network interface
- Select “test_private_subnet” for subnet
- Enter “172.21.101.254” for IP address
- Add storage
- Set hdd size to 40GBs
- Add tags
- Select “Add tag”
- Enter “Name” for key
- Enter “opnsense” for value
- Security group
- Enter “test_router_sg”
- Allow ALL traffic(ONLY DEVELOPMENT)
- I am being lazy to create a post.
- You will need to allow port 80,443,22 if you want a more secure setup
- Select “Launch
Setup Elastic IP for instance and networking
- Select “Network interfaces” on the left
- Search for “172.21.100.254”
- Copy the Network interface ID
- Search for “172.21.101.254”
- Select network interface
- Select “Action” then “Change source/dest. check”
- Select “Disable”
- Select “save”
- Select “Elastic IPs” on the left
- Select “Allocate new address” and select “Allocate”
- Select new Elastic IP, select “Action” then “Associate address”
- Select “Network interface” for resource type
- Paste Network interface ID from above
- Select “172.21.100.254” from Private IP
- Select “Associate”
Setup/Configure VPC routing tables
- Select “EC2” from AWS services
- Select “network interfaces”
- Search for “172.21.101.254”
- Copy network interface ID
- Select “VPC” from AWS services
- Select “Your VPCs” on the left and select “test” VPC
- Select “rtb-xxxxxx” for routing table
- Select routing table and select “routes” tab
- Select “edit”
- Enter “<network interface ID above>” in the target box for “0.0.0.0/0”
- Select “Save”
Setup AWS OPNsense instance
- Browse to “https://<Elastic IP of OPNSense>” and login
- Enter “root” for username
- Enter “opnsense” for password
Change root password
- Select “User” on the left then “Change password”
- Enter new password and select “Save”
Setup LAN interface
- Select “Interfaces” on the left then select “Assign”
- Select “+” and this will add the LAN interface. Should look like photo below.
- Select “LAN”
- Select “Enable interface”
- Select “Static IPv4” for IPv4 configuration type
- Enter “172.21.101.254” for IPv4 Address and set subnet to “/24”
- Select “Save” and “Apply changes”
Change some settings opnsense
- Select “System” on the left and select “Settings”
- Enter “<hostname>” for hostname
- Enter “<domain>” for domain
- Enter DNS server IP addresses under DNS servers
- Select “<time zone>” for time zone
- Select “Save”
Create instance in VPC
- Select “EC2” from AWS services
- Select “Launch instance”
- Select “Ubuntu Server 16.04 LTS”
- You can select whatever you want but I will use Ubuntu 🙂
- Instance type
- Select “t2.micro”
- Configuration instance details
- Select “test” VPC for network
- Select “test_private_subnet” for subnet
- Storage
- Accept default
- Add tags
- Select “Add tag”
- Enter “Name” for Key
- Enter “test box” for value
- Configure security group
- Allow all traffic(ONLY DEVELOPMENT)
- Please setup more restrictive ports for production
- Select Launch
Setup/Configure OPNSense port forward to instance
- Go to EC2 instances and select newly created “test box”
- Get the private IP for the instance
- Login into OPNsense webgui
- Select “Firewall” then “NAT”
- Select “Port forward” tab at the top
- Select “Add + ” in top right
- Select “WAN” for interface
- Select “TCP” for protocol
- Select “WAN address” for destination
- Enter “5000” for destination port range to and from
- Enter “<test box IP address from above>” for redirect target IP
- Enter “22” for redirect target port
- Enter “SSH port forward to test box” for description
- Select “Save” and “Apply changes”
- ssh -i <private ssh key file> ubuntu@<Elastic IP of OPNSense> -p3000
Are you able to update opnsense? I seem to get an error when try to update through the management UI.