Self-Hosted Infrastructure

Hardware Overview

While writing this blog post I upgraded the home lab with a friends old gaming rig and removed other computers in the server cluster in order to be more considerate of how much power each server was using. Overall the theoretical maximum amount of power it can use is 1130W. If it gets to that level I have a lot to worry about.

HardwareSpecs
ROG Zephyrus GA502DUAMD Ryzen 7 3750H, quad-core
Radeon RX Vega 10 and Nvidia GeForce GTX 1660Ti 6GB 60W (GeForce 431.36)
16 GB DDR4 2666 MHz
512 GB SSD
Mac Mini2.6GHz dual-core Intel Core i5
8GB of 1600MHz LPDDR3 memory
480 GB SSD
Dell optiplex SFFi7-6700 CPU @ 3.40GHz
16GB DDR4 RAM
Gaming ComputerAMD Ryzen 5 3600
PRIME B550M-K ARGB
GEFORCE GT 710
16 GB DDR4 RAM
512 GB SSD
2TB Harddrive
TL-SG2016PVLAN Switching
PoE
Raspberry Pi 4 Model B1.5GHz quad-core ARM Cortex-A72 CPU
8GB RAM
Ubiquiti Unifi U7 LiteWireless AP
WIFi 7

Below I have documented some of the quirks or problems I had when setting these systems up.z

ROG Zephyrus GA502DU

There is a very annoying coil whine that can be heard from this laptop. To stop this you can plug a USB into the computer, for some reason this dulls the coil whine to where it is inaudible. Getting a slim USB like this is what I did but these USB’s should not have any critical data stored on them as they have failed me in the past possibly due to the operating temperatures of the laptop melting the USB.

Mac Mini

You have to press alt in order to get to the boot menu. Press both alt keys in an alternating fashion when booting the system. More information can be found on the apple website .

Ubiquiti Unifi U7 Lite

It has been a while since I have setup the U7 Lite but it will not be able to find the Unifi controller unless you specify it. This will make it so that it appears in the app and you are able to configure it.

BASH
ssh ubnt@<AP-IP>

The default password is ubnt (at least in my case). It is a good idea to change the password using passwd to reduce attack surface.

BASH
set-inform http://<controller-ip>:8080/inform

TL-SG2016P

After a storm the entire network went down. I was unsure why so I plugged in the backup router so that family members were not affected and the next day diagnosed the issue. There is a big button at the top that says “save config” I thought this meant saving a configuration file to my computer so I could restore it to a working state when resetting the switch. This button actually means to save the current state.

Also with VLANS you need to set the VLAN ID in the VLAN Config menu and the PVID in the Port Config for the associated untagged port. The PVID is responsible for sending data to a default VLAN, for some reason this isn’t set automatically when setting the VLAN ID for an untagged port.

VLAN Table with PVID

Gaming Computer

The gaming computer was a broken hand me down from a friend. It originally had a GTX 1660ti in it and PRIME B450M-A. Nothing would appear on the monitor and the AMD Ryzen 5 3600 does not have an integrated GPU I immediately suspected the GPU as the main suspect. I took out my GPU on my main computer and replaced it with the 1660ti. My main computer then exhibited the same symptoms as the broken computer. I tried both the motherboard and graphic card HDMI ports with no change (my desktop has integrated graphics) and concluded that the graphics card was damaged.

The computer was very dusty and I wouldn’t be surprised if the dust had somehow shorted something in the card. To delve deeper and to see whether the damage done to the card was possibly repairable I took it apart to have a closer look.

GPU Grease

I took the photo a little after I took the dust of the top and you can see a dark splotch of something above the GPU chip. No capacitors seemed to have blown and the main culprit of why the graphics card wouldn’t work would probably be under the cooling plate. Since the cooling plate was some sort of adhesive on it I couldn’t take it off. With this in mind I called it there cleaned the graphics card with Isopropyl alcohol and some canned air as repairing the GPU from this point forwards was probably out of my skill range. I replaced the graphics cards on the motherboard with a new GT 710 and unfortunately this did not fix the problem.

I did some more troubleshooting and found two things.

  • My keyboard would not light up when plugged into the computer.
  • The fans were also not cycling or changing speed.

These were signs of a motherboard failure. I also assumed that if the GPU failed it is possible that it could have damaged the motherboard in the process as well. I bought a new PRIME B550M-K ARGB motherboard and to my surprise it booted back up again.

As a side note if you are cleaning a very dusty computer use a P2/N95 mask. I foolishly used just a normal blue medical mask and I got a little bit sick afterwards. {: .prompt-tip }

I recently got a new set of white fans that do not have RGB on them as well.

Virtualisation & Operating Systems

The servers usually run Proxmox unless the CPU doesn’t support it or it is too under powered to run multiple operating systems effectively and reliably. If a application does not have a docker image I create a Debian LXC container instead.

Network Design

Homelab Diagram

Let’s go over the network design in this section. When it comes to naming servers it is very important that you do it right as I learnt the hard way that it is not recommended to change the name of the nodes after it is in a cluster as described in the documentation . Since this is a homelab I was a little playful with my server names. All servers hosting proxmox are named after characters from Nichijou with virtual machines and LXC containers describing their purpose (docker, k3s-agent, jellyfin, etc).

If you decide to rename a node with a VM already inside it you have to move the configuration files from the old node folder to the newly generated one. This will also remove the old node from the web GUI as well. Below is a command you can use after changing the host name in /etc/hosts and /etc/hostname.

PLAINTEXT
mv /etc/pve/nodes/{NODE_NAME}/qemu_server/*.conf /etc/pve/nodes/{NEW_NODE}/qemu_server/

LAGGS was created just for fun but does server some what of a purpose. since not all of the traffic is sent outbound and some is sent internally it might lead to some congestion on the router. Therefore having LAGGS available allows for 2GB/S to be transmitted which should be plenty for our purposes.

Firewall Configuration

IDNameSubnetDescriptionDHCP
10TRUSTED192.168.10.1/24For endpoints in the home like computers, printers, and phones.192.168.10.100 - 192.168.10.199
20UNTRUSTED192.168.20.1/24Used for the guest WiFi network doesn’t allow for devices to communicate with each other192.168.20.100 - 192.168.20.199
30SERVER192.168.30.1/24Any services that I use. The only person using these services are usually me and are open to the TRUSTED network.None
40MANAGEMENT192.168.40.1/24Management VLAN holds all of the Web configuration pagesNone
60IOT192.168.60.1/24Smart lightbulbs and things like that go here.192.168.60.100 - 192.168.60.199
80WIREGUARD192.168.80.1/24DMZ for my WireGuard instance where untrusted endpoints can access services here.None

I use the 24 subnet for all networks. In a homelab setting I do not mind the size of the networks so I use 24 for all networks. There is little benefit of optimising VLANs in a Homelab setting so I do not do it. The Trusted, Untrusted and IoT VLANs have DHCP enabled allowing devices to be allocated an IP when they join the network.

Alongside this I use Unbound DNS for my DNS server which allows for redirects to the reverse proxy and allows for a block list of ads and trackers. Also by using Unbound DNS I get to see statistics which is cool.

Network Hardening

This section describes the steps takes to ensure that the network and the systems on the network are hardened to reduce attack surface and the damage that a attack might have on the network in case of an attack.

  • Change default passwords
  • Segmented Network using VLANs
  • Utilizing SSH Keys instead of passwords for virtual machines and containers
  • Utilizing a password manager to create and store important information
  • Segmenting services into different VLANs

Self-Hosted Services

If the application stack is not created in Portainer I create a folder for the application in etc/docker/containers/{application_name}/ and put the docker compose file in it.

Portainer

Portainer is used to deploy applications using docker when appropriate. Sometimes using portainer is not viable (such as hosting an invidious instance) but serves as a central management system for deploying applications.

Forgejo

Forgejo is used to store configurations for the server such as docker-compose file and configurations for switches and routers. It is also used as my main code repository I use GitHub as a mirror mainly for professional reasons but I like to keep certain projects hosted at home.

VPN Minecraft server

The Minecraft server is composed of 3 applications:

In the new update wg-easy is configured in a manner that VPN clients can only access applications on the same docker network. previously it used to be able to access everything on the same local subnet which was a security concern during the time I couldn’t segment my network and had to enforce rules using iptables.

This stack is separated on a separate virtual machine as other people from the outside access these services. I assume that all computers accessing these services are compromised and untrusted therefore principle of least privilege should be applied.

Problems and Lessons Learnt

Minecraft Server Incident

A lesson learnt about hosting a Minecraft server is to take backups frequently. When I created the Minecraft server I took into consideration both the time that we would be playing and the risk that the server would crash or corrupt. I predicted that we would be playing for around 2 weeks at the most. I also felt that the risk of corruption was quite low since something pretty major needed to happen in order for that to occur.

Around 3 days into the server being up the server crashed. After some investigation I concluded that the Minecraft server was using more RAM than was allocated in the environment variables of the server. I believe that it is possible that a memory leak happened since this was modded Minecraft and it eventually filled the allocated memory of the virtual machine before crashing. I didn’t focus too much on diagnosing the issue as I felt it was more important to focus on what can be done in the future.

When loading the world back up again my friend came to find that his equipped Pokemon had disappeared and was devastated because it took a lot of time to level, gather and find. When exposing services to friends and family they rely on you to maintain their data. This data should be handled with the most upmost of respect. Therefore After this I constructed a small CAR (Corrective Action Report) stating:

  • When dealing with services that involve handling the data of others parties the CIA triad must be enforced to a production level capacity.
  • Backups must be kept in appropriate intervals.

Very glad that I learnt this lesson in a controlled setting instead of a situation where there is more on the line. When other people are involved the utmost respect should be given to their time and data and that is something I did moving forward from this incident.

Storm Incident

One night it was storming and the power went out. When the power turned back on no one was able to access the internet. This was due to the switch completely resetting and turning all settings back to default. I didn’t know at the time but there is a big button on the top that says “save config” this button makes it so that on restart all settings and reverted back to the previous save. I thought it meant that It would download a config file onto my computer so I never pressed it.

The highlights the importance of fault testing to see whether systems can hold during a blackout. Backup power systems on enterprise systems are really cool where they have a UPS that turns on while the backup generator powers on. I have nothing like that but that is something I might play around with possibly in the future.

Planning is VERY Important

When I was deploying new systems sometimes I came across something that I didn’t know I needed for a new problem came up that I was unprepared for. Planning is an integral part of network and software deployment and improper planning and preparation can lead to increased costs or solutions that are sub-optimal over time these errors build up and can make the network expensive to maintain.

In my own homelab I have a very limited budget. I do not like spending more than I have to on these systems. The desktop I am using as the server currently was a broken hand me down that I repaired. The laptops are old computers. The router is a refurbished office computer. Only rarely do I buy things. But there were alternative solutions that I missed when building my network. One such thing would be flashing openwrt onto a openwrt capable router. This would have saved a lot of money in both power and hardware. Though, my computing network skills would not have been capable enough to configure and deploy such a complex piece of software in a secure and pragmatic manner.

This is why moving forward

Future Plans

I have used k3s in the past for my homelab but gradually moved things over to docker. I want to integrate k3s more in my homelab but I don’t think I really have the infrastructure where I think it can be used to it’s fullest extent.

A media server would be nice but the current server infrastructure doesn’t allow for very efficient trans-coding due to the desktop rig no GPU available for PCIE pass through. I thought about using my laptop’s integrated graphics since that has two but that is a very risky solution since laptop GPUs are not built for that sort of purpose.

I want to use a more sophisticated reverse proxy like standalone nginx or caddy instead of relying on nginx proxy manager. This would be more accurate to actual production level systems. Since I am just testing things out and configuring things quickly the solution of using proxy manager is pretty good for the time being but later down the line I want to increase my knowledge when it comes to these systems.

Power consumption is something that I want to be mindful of since running the server over a long period of time can eat into costs. This is especially so because the hardware for the homelab is not optimised for energy usage which means energy is lost. In the future I will experiment with solutions that might reduce the amount of power that the entire server uses.

History and Previous Versions

My homelab has gone through several iterations and for a long time it barely functional as I kept running into limitations and immediately wanting to expand. My Homelab started in a very simple way: I found an old Lenovo G50-45 in the garage and decided to use it as a dedicated server for Minecraft. I installed Debian, curled PaperMC and used Hamachi as a VPN. At the time, I had no idea what Proxmox was or even what homelabbing was. I just wanted a system that could run for hours on end without shutting down.

One day my friend wanted to host a modded Minecraft server and was describing all of the things he and his brother were doing. He talked about Proxmox, Docker, Kubernetes, things I knew about but never actually used. As his hobby server outclasses mine at the time I took it as a challenge to try to make my server better I wasn’t familiar with networking at the time but had a good foundation in programming and Linux. Creating servers also generated value in my personal life as I realised I could offer services to friends and family with my server. This was my introduction to homelabbing.

I immediately gathered all old computers I had. This included an old Dell XPS, a Mac Mini, A Dell Latitude E5400 which I had to use tools online to reverse engineer the recovery BIOS password to select the boot device in the BIOS. I immediately started to install proxmox on each of these devices apart from the old Dell Latitude in which that would just be a plain Debian installation. This is when the XPS incident happened.

While installing Proxmox on the Dell XPS there was an error in which it couldn’t install on the SSD. I read online that maybe I should try switching to legacy mode in the BIOS. There has been many times where I played around in the BIOS and made a mistake but this can be remediated with draining the power from the CMOS battery. The risk to doing this was low and I thought I would be able to go back in no time. With this in mind I turned on the legacy boot and selected the USB drive from the boot menu. Nothing… Not even the Dell logo appeared on my monitor. My heart sank but I felt like this problem could be solved no problem. Just got to reset the BIOS.

For the next 3 days straight for 36 hours I did everything I could hardware wise. Unplug the battery, undo the screws, take out the copper plating for the CPU, wipe the thermal paste off with Isopropyl alcohol take the motherboard out, flip it over and take the CMOS battery out. I did many variations of this including holding down the power button to drain residual energy, power it on without the battery plugged in, re pasting the CPU in case it was thermals shutting down the laptop. It got to a point where I got tetris syndrome with the order I would take the screws out and in. Overall a good experience and it made me more comfortable with taking apart electronics and was a good stepping stone to the sort of hardware trials I would face in the future.

With the Dell XPS out of commission I next turned my attention to the malware infected Mac Mini I had as a child. I say Malware infected because I would install anything on that thing and there probably a lot of bloatware on that device. The hard drive on that device were on it’s last legs and boot up times would go for an hour (not exaggerating). I decided that the Mac Mini needed an upgrade so I bought a new Kingston A400 480GB 2.5in SATA III SSD and new screwdriver. The teardown for this device was very troubling. Step 8 required you to insert a tool into two holes in the motherboard in order for it to pop out. I didn’t have this tool but online people were doing this with two screwdrivers instead. Over the period of two hours me and my brother kept playing chicken with the mac mini trying to pop out the motherboard until we put our full body weight on both screwdrivers before it eventually gave way. There was no damage to the bottom of the hole only the motherboard was a bit chipped as we tried to pull it towards us when inserting the screwdrivers.

The boot times for the mac mini immediately improved to where it was now usable again. We were immediately transported back to 2014 we booted up the Mac and we played around with the old safari watched as some websites broke and explored the different things you could do on it. Eventually we said goodbye and installed Proxmox on it.

Shortly after that I installed a Network Ad Blocker on one of the devices. This alone caused major outages since my router did not support custom DNS servers. This meant that I had to disable DHCP on my router and make turn the Ad Blocker into a DHCP server (this is a feature that many network wide ad blockers support). At the time I think there were three major things wrong with the network.

  • When I wanted to do something with my server the internet would go down.
  • Since there is an expiry date on leased IP addresses sometimes I would be out of the house and get a phone call saying that the internet was down.
  • No VLAN support

Some of these problems are solvable like assigning a static IP address to the DHCP server (I don’t think this occurred to me at the time). But I wanted more control over my network so I began with getting a new switch. I bought a TL-SG108E so that I could utilise VLANs. My initial impressions of VLANs was that only switches defined these networks and that there was no correlation between VLANs and sub netting. It is with this thought train where I got really stuck trying to set this up as I couldn’t figure out how I could make two networks communicate with each other.

A little bit annoyed with VLANs I looked over at some new router solutions. I had bought the cheapest switch that supported VLANs but I remember seeing a LTT video in my recommendations going over building a DIY router . I knew about OPNSense and PfSense previously but I didn’t have any server capable of running it since it requires at least 2 NICs. So I bought 4 items and these were:

  • Refurbished Dell Optiplex SFF
  • 1 GB/s 4 Port Ethernet NIC
  • Ubiquiti Unifi U7 Lite
  • TL-SG2016P

Small Form Factor is needed as that is the smallest factor that can fit the 4 port Ethernet NIC. The Ubiquiti Unifi U7 Lite required PoE in order to work which required me to buy a new switch. The switch also supported LAGGS which I thought would be really cool to setup for fun. These purchases was probably the best purchases I could have made for the homelab.

If you are buying a 4 Port Ethernet NIC you NEED to get an intel based NIC otherwise OPNSense won’t work properly. There are also a lot of fake cards that break easily. I got quite lucky with my purchase since I got mine on sale from 4cabling and it has not broken since. If you are buying from another source I felt like this was a pretty good reference to know whether what you are buying is genuine.

License

Author: Hugo Narrow

Link: https://tomatonator.dev/posts/self-hosted-infrastructure/

License: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.