This is a LONG writeup, if you wish, here is a link to the PDF version: VirtualFirewalledNetwork
So recently I wanted to create a more secure network for hosting honey pots. Since honeypots are meant to be probed and sometimes pwnd I did not want them on the same network as my other personal devices. I however, don’t have a ton of equipment in my lab to do extremely advanced networking so instead of using hardware, we virutalized the environment! In the end, our logical environment looks something like the following:
Physical Lab Layout
Our physical structure looking like the following:
My home-lab setup consist of the following hardware:
And the following Software:
CentOS 7 – Host OS on the ML110
DD-WRT – Installed on the ASUS N66U
Fedora 26 – Installed on Laptop
The exact server is NOT required for this to work neither is CentOS. You can instead use any old(but moderately powerful & virtualization ready) desktop with a stable Linux distro that supports QEMU/KVM. I will not be going over how to install CentOS or QEMU/KVM in this article. You WILL need to have an extra NIC port on the server though if you want to run some VMs on your LAN and some in the firewalled network!
DD-WRT is what I will be using to create my separate networks, so it, or a firmware that supports VLANs/network isolation is required.
Fedora is also not required, but it is my preference. Virtual Machine Manager is available for many Linux distributions so you can use your favorite distro.
Creating an Isolated VLAN network with DD-WRT
When we create honeypots, we do NOT want to jeopardize our own private home network. With DD-WRT we can create a separate network to attach our VMs to in order to keep them isolated away from our other personal devices.
1. Go to setup > VLANs and pick a port to place on a separate VLAN.
Here, I chose to assign port #1 to VLAN 3. Then apply your settings. If you do not have a cable plugged into the port, the status indicator above will be red (see ports 2 and 3 in the example). If you have a cable plugged in, the status indicator will be green(W, 1 and 4). Try to use a port with nothing plugged into it, if none are available try to figure our a way to free up a port as any traffic coming off the port in the future will be separated from the rest of the network!
2. Go to Setup > Networking and create a new bridge. You can name it what you like.
I have three bridges, you may only have two. For this tutorial I will be using “br2”.
3. After you created a new bridge, assign your new VLAN to the new bridge:
Here, I assigned vlan3 to br2. This will allow your VLAN to share your WAN port and therefore provide your new subnet with internet access.
4. Scroll down a little and you will see the new network configuration section for your bridge:
Here you MUST enable “Net Isolation”. This will make sure that any traffic coming from this subnet will not reach your other subnets.
For the IP address, use whatever value you want but make sure it is in a different subnet than your private LAN! My LAN is in the range 10.0.0.0/24, so for my subnet I used 10.2.0.0/24.
5. Make sure you then click Apply Settings! Your router may restart after this, but it’s okay!
You now have a new subnet on your home network. Remember what port that VLAN is on, and then continue to creating the VM environment!
Creating a Virtual Network and Machines with QEMU/KVM
Now that we have a private subnet set up, we need to create some VM (or VMs) to run on the network, and a VM for our pfSense firewall. I will demonstrate doing this in Virtual Machine Manager.
1. In Virtual Machine Manager go to Edit > Connection Details > Virtual Networks.
2. Then click the ‘+’ at the bottom of the list.
Name it whatever you like.
3. Un-check ‘Enable IPv4 network address space definition’. This is useful to have enabled if you want the virtual network to also act as a router/gateway/dhcp server. We instead want to handle these tasks through pfSense so we need to disable it.
4. Same case for IPv6
5. Make sure ‘Isolated Virtual network’ is selected then click finish!
Now we have a virtual network created. This is going to be our firewalled network. Every device in this network is isolated away from our private network and in the event of a compromise, can easily be dealt with. What you now created, is the equivalent of a virtual switch. Now, we need to add a client to this switch to be the honeypot and pfSense to the switch to act as our router/gateway.
6. Create a client VM in Virtual Machine Manager and assign the new network to the virtual NIC port. I am not going to go over all the steps to create a VM in Virtual Machine Manager, but when you get to the networking step, this is what it should look like:
This will attach our new VM to our new network.
7. Create ANOTHER VM but for pfSense instead and do the SAME thing for the network selection. Except this time make sure you check ‘Customize configuration before install’.
8. Now on the new screen, click ‘add hardware’ at the bottom of the list and click Network:
This time, instead of the network source being the firewalled network, you want to select the NIC port of the server that is connected to the port you assigned the new VLAN to earlier! I created my new VLAN on port 1 on my router, that port is connected to interface ‘enp2s0’ on my server so that is what I selected here. You also want to make sure you are select ‘Bridge’ as the source mode!
What this does, is give pfSense one NIC inside the firewalled network, and one NIC connected directly to our new VLAN gateway (which is bridged through our router to the internet). Thus, allowing network traffic to flow from our firewalled network to the internet but ONLY through pfSense, which is exactly what we want.
Installing & Configuring a pfSense Virtual Machine
So now we have the following, a private sub-net on our router, a virtual switch with two VMs connected (our honeypot & pfSense) and pfSense with two NIC ports installed (one inside the honey net, one inside our private sub-net). Now, we need to configure pfSense to act as a gateway. This will allow our machines inside the virtual network to connect to the internet through pfSense (so that then we can do some real fire-walling on our virtual machines if we need to). To do that, we need to configure pfSense. So once you install pfSense on a virtual machine you should see the following:
1. Lets set up our WAN and LAN interfaces. The LAN interface will be the NIC port of pfSense that is inside our virtual network and the WAN interface will be the NIC port of pfSense that is connected to our sub-net gateway. So press 1.
The re0 and re1 are both of my virtual NICs I installed to the pfSense VM. To figure out which one is in which sub-net go to View > Details on the virtual machine window. On the left side of the window, it will show you the last 3 bytes (hextets?) of the MAC address. Just match these up to what pfSense shows. The one bridged to your server’s NIC will be what we set up as the WAN port and the one in the virtual network will be the LAN port.
Once you have figure this our, go back to View > Console and press ‘n’ since we won’t be setting up any VLANs now.
2. Now we just enter the interface that will be connected to the WAN. For me, it was the MAC address ending with :69 so here I type re1 and press enter.
3. Now we set up the LAN, do the same thing as above just use the LAN interface instead (for me it was re0).
4. Press y if everything looks correct
Now you should be back at the main pfSense menu and your WAN and LAN interfaces should both be assigned. Now we need to assign the IP addresses to the interfaces. Since the virtual network will be in its own subnet, you will need to think of an addressing scheme. I’m going to use the 10.0.1.1/24 network for my subnet.
2. Press 2 to set up the IP addresses. Then select 1 (or whichever option corresponds to your WAN interface). You probably won’t have an IP for your WAN interface yet since we didn’t set up DHCP on the sub-net, so you can enter in any IP address in your sub-net that you like, since my gateway is 10.2.0.1 and my server’s NIC port is 10.2.0.2 I opted for 10.2.0.3.
3. Now we need to set up the upstream gateway IP address. This will be the IP that all traffic coming into pfSense will be forwarded to. In our case, its the 10.2.0.1 bridge we set up on our router earlier. Then enter nothing in for the IPv6 options.
5. Now perform the same steps(2 & 3) as above to set up our LAN interface IP. If you look at my virtualization diagram in the prefix, you will see my firewalled network subnet is 10.0.1.0/24. So for my LAN interface IP I assigned it the address 10.0.1.1
Ensuring everything works
Honestly, that’s about all there is to it! By default, pfSense will allow all traffic from the LAN and forward it to the upstream gateway so if you log into your VM on the firewalled network you should now be able to set up your IP address information like so:
And you will have an internet connection, through pfSense, on your virtual honey-network!
Now you can set up VMs inside this network, to act as honeypots and filter all traffic however you wish through pfSense!
You can log into pfSense web interface from the private network by browsing to your gateway IP: 10.0.1.1