Preface#
This will be a continuous series of themed articles, starting from the basics of setting up a home lab and gradually progressing to more advanced learning in the areas of systems, networks, and services. I will try to describe everything in simple and understandable language from the perspective of a beginner. The series of articles will cover topics such as home networks, routers, Linux, data storage, NAS, and service deployment. If you encounter any problems during the process, feel free to leave me a message.
Reasons for setting up a home lab#
homelab: a laboratory of (usually slightly outdated) awesome in the domicile
From a literal translation, it can be said that a homelab is a home-based laboratory. By extending this concept to networks and services, you can do many interesting things, such as:
- NAS storage: downloading and storing any data (photos, materials, code, etc.)
- Media library: from a simple network shared folder to a comprehensive Jellyfin or Plex service for hosting, managing, playing, and transcoding media
- Network management: device throttling, traffic auditing, firewall policies
- Application development: creating development environments, caching, data storage, etc. for side projects
- DevOps: using tools like Ansible, Salt, and Kubernetes to operate and maintain multiple servers, VMs, or LXC containers
If you happen to be a software application developer, a homelab is the best way to expand your skills and serve as a good experimental field for learning about network topology, Linux systems, and security management. For most people, they may have heard of NAS servers to some extent, which is actually one of the practical applications of a homelab.
Don't be intimidated by its name. Essentially, it is just running a bunch of services on an operating system.
Considerations for self-building#
Regardless of how attractive the above points are to you in building your own homelab, you should carefully consider whether you really need it. After all, setting up a complete system will require a lot of effort and some investment. Don't create a need without actually having one.
This series of content will prioritize the use of open-source and free solutions. If they cannot meet the requirements, I will share some commercial solutions.
Commercial solutions#
Commercial solutions mainly involve selling software services to provide solutions for network management, data storage, etc. The mainstream solutions on the market are:
- Synology: Sold with hardware, it is a very satisfactory software system in all aspects and is very user-friendly for beginners.
- QNAP: Software sold with hardware, it has a price advantage over Synology, but its software system is relatively inferior.
- UnRaid: A commercial NAS system that provides fast expansion, Docker, and VM management.
- UniFi OS: Mainly used in the Dream Machine, it is a very expensive system.
In general, commercial products are all-in-one solutions, and the cost will be higher than self-building. However, this is beyond the scope of homelab considerations, so I will not go into detail here.
Open-source & free solutions#
Building a homelab will inevitably start with hardware and software, and then decide on the network topology.
Hardware selection#
The hardware environment in China and abroad is very different. In China, there are many discussions about foreign junk and modified hardware, such as the E3/E5 cult and junk enthusiasts. If you are knowledgeable in this field, congratulations, you can save a lot of money. If you are not, don't be discouraged and spend money on data security. Also, don't blindly buy junk hardware, as there are risks in picking up trash. Some hardware may be overclocked too high, resulting in low cost-effectiveness and not worth buying.
The most critical parts are CPU, memory, motherboard, network, and hard drives.
- CPU and memory are easy to understand. The more CPU cores and memory capacity, the better. If you have requirements for media playback, you need a CPU with good core support.
- The motherboard depends on the number of network ports and expansion slots. If there are not many network ports and hard drive support, you will have to rely on expansion slots.
- Network conditions are crucial. WiFi 6 transmission speed is still not as good as gigabit wired connections. Evaluate the minimum requirements for gigabit networks for your home's modem and router. For wired connections, try to use CAT5e/CAT6 specifications.
- NAS applications have higher requirements for hard drive capacity and specifications. SSDs are not a strong requirement. If you have enough money, you can use SSDs for everything.
Each of these topics can be expanded into a very large topic. I may organize some external resources for you to supplement your knowledge in this area. There are also some ready-made hardware solutions on the market that you can consider:
- Intel NUC: Small models do not mean weak performance. The latest 12th generation NUC is a good choice in all aspects.
- Lenovo ThinkCentre series: Slightly larger than NUC, this series is very extensive and has a long history. There are also many affordable second-hand and refurbished options, but they may require some tinkering.
- HP MicroServer Gen series: Gen8/Gen10 are currently mainstream homelab solutions with standard server specifications and features. (I have a Gen 8 server in use)
- Various development boards: For example, the Raspberry Pi has been able to handle some homelab applications since the 3B model. There is abundant information and accessories available both domestically and internationally. The only downside is that due to the impact of COVID-19, its price is high in China. You can consider other mature development boards.
- Various mining rigs: The mining industry in the blockchain era is filled with many mining rigs, such as Star Trail, Green Disk, and Honey Badger. Some hardware parameters are good, but they may require adjustments or modifications to use them quietly.
The simplest version is to find a long-lasting, unused laptop or desktop computer to get started (if the power consumption is too high, then forget it).
Software deployment solutions#
After preparing the hardware, we need to consider which software deployment solution to use. It is usually divided into three categories:
- Traditional Deployment
- Virtualization Deployment
- Container Deployment
In cases where the hardware performance is still decent, traditional deployment solutions are not usually used. The priority for a single host is: containerization > virtualization > traditional deployment. If the machine has good performance and technical interest, the priority is: virtualization > containerization > traditional deployment.
Traditional Deployment#
Traditional deployment is usually done on bare-metal machines, so I equate them. It involves installing an operating system such as Windows, macOS, or *nix (Unix/Linux) on the hardware host and directly installing and deploying services. It may not sound special, but there are many operations and maintenance tools on the market that can help with system installation, environment configuration, maintenance, and data backup, such as Salt, Ansible, Puppet, etc. However, they require some learning curve and cannot be used out of the box. It may also be a problem to fully utilize the hardware's capabilities.
Virtualization Deployment#
- ESXi: A hardware virtualization solution developed by VMware. It has a simple and user-friendly interface and powerful features, but it is a paid solution.
- Proxmox: An enterprise-level virtualization system based on Debian. It supports hardware passthrough and scalable clusters. It has a slightly higher learning curve but is commonly known as PVE.
There are not many options for open-source solutions in the virtualization deployment category. PVE is the most mature and actively developed solution on the market. Even if you encounter strange problems, you can solve them by using search engines.
Container Deployment#
- Docker: The pioneer of modern containerization. It sparked the development of the following two solutions.
- Containerd: Developed by Docker's parent company and grown in the CNCF foundation. It provides nerdctl as a replacement for the docker CLI.
- Podman: A Docker-compatible solution led by Red Hat.
In summary, if you don't understand, just use Docker.
Base System#
If you choose traditional deployment, you can use any operating system that you are familiar with and meets your requirements.
Application Services#
Once you have prepared the hardware and software foundation, you need to consider a wide range of application services to expand and enrich your homelab.
Beginner-level Solutions#
Software Router#
- OpenWrt: The most popular solution in China this year. There is a branch version called immortalwrt in China.
- Asuswrt-Merlin: Asus' open-source router firmware. There is also a modified version called koolcenter in China.
- DD-WRT: A firmware that was popular during the early days of router flashing. It is now gradually fading away due to limited hardware support and infrequent updates. Tomato, which supports multiple WANs, was popular at that time.
Gateway#
- Nginx: A traditional gateway used for hosting or reverse proxying website services.
- Caddy v2: A modern HTTP/2 gateway that supports Let’s Encrypt and has a user-friendly UI.
DNS#
- Dnsmasq: The foundation for everything, used for configuring DNS and DHCP services.
- Pi-hole: A router system that focuses on privacy protection and ad filtering. It is commonly used by overseas users.
- AdGuard Home: A service that focuses on privacy protection and filters all network ads. It provides a user-friendly UI.
- SmartDNS: A DNS service that accelerates DNS resolution and traffic routing.
- MosDNS: A DNS service that combines the advantages of SmartDNS and AdGuard Home, but has a more complicated configuration.
Firewall#
- iptables: The commonly used built-in firewall in Linux.
- nftables: The official enhanced version of iptables. It is the future trend and will gradually replace iptables.
- pfSense: A popular open-source firewall used overseas.
NAS#
- OpenMediaVault: A comprehensive NAS system with low hardware requirements.
Service Deployment#
- Portainer: A simple and easy-to-use container deployment solution.
Media#
- Jellyfin: A media playback service for movies, TV shows, etc. It supports media scraping and synchronization of watch data.
Applications#
- Bitwarden: An open-source password generation and management service that can completely replace 1Password on all platforms. It is recommended to use vaultwarden, which is a Rust-based rewrite by developers.
- ZoneMinder: An open-source multi-camera and recording management service.
For more applications, you can follow my self-hosted service collection.
Advanced Solutions#
The following solutions are limited to what I can currently think of within my capabilities. Please be kind as my abilities are limited.
Gateway#
- Traefik: An open-source reverse proxy and load balancing tool.
NAS#
- TrueNAS: The preferred data storage solution used overseas. It is based on the ZFS file system, and the maximum disk capacity is determined by the amount of memory. It was previously known as FreeNAS.
Service Deployment#
- Kubernetes: A modern container orchestration system. It is the ultimate tool for "cloud YAML engineers" 😆.
Conclusion#
The possibilities for homelab are endless. Don't limit your imagination to the so-called AIO Boom that has been popular in China in recent years. Using PVE to deploy everything, or even using OpenWrt + Docker to deploy various services, may encounter problems. Moreover, if the server crashes, everything will be lost.
Also, don't worry too much about the power consumption of the server. As long as it is not a power-hungry monster consuming 35W or 65W, it won't save much on electricity bills. Here is a positive example: although I use an X99-T8D + E5 2696V3*2 + Jinhetian 6100 dual power supply, the developer mainly uses it for their own scenarios, so it is not a waste.
Finally, my advice is not to take the OpenWrt and NAS articles on various Chinese information consulting websites too seriously. Instead, it is better to read the official documentation and participate in discussions in official communities .