Building a Home Server From an Old Laptop

Turning a spare laptop into a Debian home server: choosing the operating system, setting it up remotely without locking yourself out, publishing services through a Cloudflare Tunnel, and fixing an AdGuard Home container that ran but couldn't be reached.

Takumi Yamada
· 13 min read
homelablinuxdebiandockerself-hosting

Renting a (Virtual Private Server) means paying every month. A home is paid for once.

As a student, that's an easy choice. The cheapest useful cloud server costs money every month, forever. My old laptop, which had been sitting unused in a room, costs nothing, and its hardware is already better. So I turned it into a server.

My old laptop, the one that became the server: a Dell with a Japanese keyboard, lid open, screen dark

To be clear about which machine does what: the five-dollar VPS that runs this website stays where it is. A public web server needs an address that never changes, and it shouldn't stop when the power in my flat goes out. The laptop is for everything else, the services that only my own home network needs to reach.

This is the build log: what I chose, why I chose it, and the few places where things went wrong.

Why an old laptop, of all things

People who run servers at home will often tell you to buy a Raspberry Pi, a used mini PC, or parts for a proper (Network Attached Storage). Those are all good options, for later. For a first server, I think the laptop you already own has some very useful advantages.

  • It's free. That's the whole point.
  • It has a battery built in. A short power cut doesn't switch your server off. People pay for a separate backup power unit, called a UPS (Uninterruptible Power Supply), to get that for a desktop computer.
  • It has a screen and keyboard attached. When the network breaks and you can't log in remotely with (Secure Shell), you don't have to find a spare monitor.

The downsides are real, but manageable. A laptop's fan is louder than a Raspberry Pi with no fan, and an old processor can use more electricity than modern low-power hardware. For a machine that sits in a room running a few , that's a fair trade.

Choosing the OS: why not Arch, why not Ubuntu

I use Arch Linux on my desktop, so it was tempting to install what I already know. But a server needs the opposite of what a desktop needs.

On a desktop, getting the newest software quickly is useful. On a server, you want software that doesn't change, and Arch changes all the time on purpose. That matters for two concrete reasons.

First, you can't safely run Arch's update command, pacman -Syu, automatically in the background. Arch updates sometimes need a person to merge settings files by hand, so someone has to watch each update. Second, the is updated almost every week, and a kernel update needs a restart. A server should be a machine you can leave alone, not one you have to watch.

Ubuntu Server is the usual first suggestion. But if you already know your way around Linux, Debian uses the same apt package system, comes with less software installed, and doesn't use Snap packages. It uses less (Random Access Memory) and less (Central Processing Unit) when it's idle. If the goal is to install and leave a laptop running in a room for three years, I think Debian's stable version is one of the best choices there is.

OSBest forFootprintPackage manager
Ubuntu ServerEasy troubleshooting, very large communityMediumapt and Snap
Debian (stable)Pure stability, nothing extra installedLightapt
Proxmox VERunning several separate virtual machinesHeavyWeb GUI and apt
Alpine LinuxGetting the most from very old hardwareTinyapk
Rocky LinuxLearning enterprise Red Hat systemsMediumdnf

So I chose Debian. One note about the download page: the version for a normal 64-bit PC is called amd64, even if your processor is made by Intel. AMD created the 64-bit version of the x86 design in 2003, and the name became the standard label for all 64-bit PC processors. Download the netinst image. It's small, and it downloads everything else from the internet during the installation.

Write it to a USB (Universal Serial Bus) stick, start the laptop from the stick, and accept most of the default installation choices. The interesting part starts after the restart.

First boot setup: five small jobs

A fresh Debian installation is an empty machine. Before it can be a server, it needs five things.

1. An editor

First things first: run sudo apt install neovim before anything else.

2. Stop the lid from killing the server

A laptop goes to sleep when you close its lid. For a server, that means it stops working when someone closes the lid while tidying the room. The fix is one line in the file /etc/systemd/logind.conf.

#HandleLidSwitch=suspend      ← change this
HandleLidSwitch=ignore        ← to this

Then apply the change.

sudo systemctl restart systemd-logind

Now the lid can be closed, and the server keeps running with its screen off, so it takes up very little space.

3. Remote access

Install the SSH server and check that it's running.

sudo apt install openssh-server -y
sudo systemctl status ssh

Find the server's address with hostname -I, then connect from your main computer.

The first time you connect, you are asked to accept the server's host key fingerprint, a code that identifies the server. From then on, the laptop never needs its own keyboard again, and everything below happens over SSH.

4. A static IP, set on the router rather than the server

Your services will be found at the server's address on your (Local Area Network), so that address must never change. There are two ways to fix it in place, and the choice matters more than it seems.

The first way is to set a static IP (Internet Protocol) address in Debian's own network settings. That works. But it also means that one typo in a settings file, typed over SSH, disconnects you from the machine you were setting up.

The second way is a DHCP (Dynamic Host Configuration Protocol) reservation on your . The router promises to always give the same address to your server's , its hardware ID. The server itself keeps its default network settings, which are known to work, so there's nothing to break.

ROUTERDHCP reservationserver's MAC192.168.1.50asks for an address, as alwaysthe same one, every timeSERVERdefault DHCP config
The address is pinned on the router. Nothing changes on the server, so there is no config file to mistype.

The reservation is the safer choice, especially when you work remotely. You need two facts.

ip link                      # the MAC address of the active interface
ip route | grep default      # your router's IP, e.g. "default via 192.168.1.1"

Open the router's settings page by typing its into a browser. Find the section called DHCP, LAN Setup or Address Reservation, because every router maker puts it somewhere different. Reserve your server's current address for its MAC address.

5. A firewall, in the right order

We'll use UFW (Uncomplicated ). Here, the order of the commands matters. You are setting up a firewall over SSH, so you must allow SSH before you turn the firewall on. If you do it the other way round, the firewall cuts your connection and locks you out of your own machine.

sudo apt install ufw -y
sudo ufw allow 22/tcp     # FIRST: keep your own connection alive
sudo ufw enable           # it warns about disrupting SSH, but 22 is open
sudo ufw status           # confirm: active, 22/tcp ALLOW
ALLOW FIRSTthen enableufw allow 22/tcpufw enableyour SSH sessionstill connectedENABLE FIRSTlocked outufw enableufw allow 22/tcpyour SSH sessioncut before you can type the second command
The same two commands in both orders. The line underneath is the SSH session you are typing them over.

The base system is done. It runs without a screen, it can be reached remotely, its address is fixed, and it has a firewall. Now it needs something to run.

Docker

Everything this server runs will be in containers: packaged programs that each run separately, with everything they need included. So Docker, the tool that runs containers, goes on first. Debian is so minimal that even the download tool curl isn't installed at first.

containers:each has its ownfiles and portsADGUARD HOMEone containerANOTHER SERVICEanother containerTHE NEXT ONEstarts and stops themDOCKERshared by all of themDEBIAN AND ITS KERNELthe hardwareTHE LAPTOP
What a container is on this server. Each service gets its own box, and they all share one kernel.
sudo apt update && sudo apt install curl -y
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Then add yourself to the docker group, so you don't need sudo for every command, and test it.

sudo usermod -aG docker $USER
newgrp docker
docker run hello-world

When you see "Hello from Docker!", the server is ready to run things.

Exposing it to the internet: Cloudflare Tunnel

The traditional way to make a home server reachable from the internet is port forwarding. You open on your router and send them to the server. It works, but then your home's IP address is public, and your router is the only thing protecting you. And some (Internet Service Providers) share one public address between many customers, using what is called carrier-grade (Network Address Translation), which stops port forwarding from working at all.

A Cloudflare Tunnel works the other way round. A small program on the server connects out to Cloudflare and keeps that connection open. Visitors go to your , Cloudflare receives them, and their traffic travels back to your laptop through the connection that's already open. No ports on your router are open to the outside, and your home IP address stays private.

FORWARDINGan inbound holeVISITORSERVERROUTER, PORT 443 OPENTUNNELdialed from insideVISITORCLOUDFLARESERVERROUTER, NOTHING OPENdialed by the serverrequests ride it back
With forwarding the connection comes in through a hole in the router. With a tunnel the server makes the connection itself, and visitors arrive over it.

You set it up from a website. You need Cloudflare's Zero Trust dashboard, which is separate from the normal (Domain Name System) one. The free plan asks for a payment method, but doesn't charge you.

  1. Go to Networks, then Tunnels, then Create a tunnel. Give it a name such as home-server.
  2. Choose your system: Debian, 64-bit.
  3. Copy the install commands it shows into your SSH session. They add Cloudflare's package source and install the program.
  4. Copy the Install as service command. This registers the tunnel with , so it starts when the server starts and keeps running.
  5. Skip the option to run it by hand. That only runs while your terminal window is open, which is the opposite of what a server needs.

Within seconds, the dashboard changes from "waiting for your tunnel to connect" to a green Connected. The last step is to link a name on your domain to a port on the server. From then on, anything the server can reach on its own ports, the world can reach on your domain through Cloudflare, while your home network accepts no connections from outside.

Network-wide ad blocking with AdGuard Home

The classic first service to run yourself is a DNS sinkhole. Tools such as Pi-hole and AdGuard Home answer every DNS lookup for your whole network, and check each one against lists of known ad and tracking domains. When your smart TV asks for the address of a known ad server, the sinkhole answers with nothing. The ad is never downloaded, so pages load faster and the ad uses none of your bandwidth.

SMART TVADGUARDblocklistsaddress of an ad server?nothingaddress of any other site?the addresson a blocklist, so the adis never downloadednot on a blocklist,so answered as normal
Two lookups from one device. The outlined one is the lookup that gets blocked.

I chose AdGuard Home and ran it with Docker Compose. First, open its ports in UFW.

sudo ufw allow 53/tcp      # DNS
sudo ufw allow 80/tcp      # web interface
sudo ufw allow 3000/tcp    # first-run setup wizard

Then I ran docker compose up -d, opened port 3000 in the browser for the setup wizard, and got nothing. A blank screen.

That started the most interesting debugging session of the whole build. I think it's worth going through, because each step works for other problems too.

Phase 1: is the container even running?

docker ps -a

The status column said Created, not Up. Docker had made the container but refused to start it. That almost always means a port the container wants is already used by something else on the server.

Phase 2: who owns port 53?

AdGuard is a DNS server, so it needs port 53. On many systems, a service called systemd-resolved already uses that port. So I asked the system directly which programs were listening.

sudo ss -tulpn | grep :53

In my case, port 53 was actually free. The only program listening was cloudflared, on a random high port, which is harmless. So port 53 wasn't the problem, and the container's logs confirmed that DNS could start. I checked the next possibility.

Phase 3: the port 80 squatter

Running docker compose up -d again finally showed a clear error.

Error response from daemon: ... failed to bind host port 0.0.0.0:80/tcp:
address already in use

It was the same kind of problem on a different port.

sudo ss -tulpn | grep :80

The cause was Apache, a web server that Debian's installer had set up by default. On this machine, everything runs in containers, so I switched Apache off.

BEFOREApache installed:80host portAPACHEgot there firstADGUARDwants port 80 tooaddress already in useAFTERApache removed:80host portADGUARDport attached
A port on the host can belong to one program at a time.
sudo systemctl stop apache2
sudo systemctl disable apache2

Phase 4: the zombie container

With Apache gone, docker compose up -d showed the container as Up. But the setup page still wouldn't load, and docker ps showed the ports column completely empty.

Here is what had happened. When Docker first hit the port 80 conflict, it stopped setting up the container's network halfway. The container existed, but its ports were never connected. Running up again only restarted that same broken container. It was running but couldn't be reached, which is why I call it a zombie.

The fix is to delete the container and build it again, now that the ports really are free.

docker compose down
docker compose up -d --force-recreate
docker port adguardhome     # should print: 3000/tcp -> 0.0.0.0:3000

The ports were connected, I refreshed the browser, and the green AdGuard welcome screen appeared. It took much longer than I would like to admit.

One last trap in the setup wizard

The wizard's last screen helpfully lists the IP addresses to set on your devices. Don't use them.

AdGuard runs inside a container, so it shows its internal Docker addresses. If you point your router's DNS setting at one of those, every device in the house loses the internet at once. The address every device should use is the server's real LAN address, the one you reserved on the router earlier.

DEVICESDNS settinguse this oneSERVER192.168.1.50LAN addressCONTAINERDocker addressfrom the wizardpoint DNS here andthe house goes offline
Two addresses for the same service. The wizard lists the inner one, and your devices need the outer one.

For block lists, the small community lists are the right choice for a home. They block enough trackers and ads to be useful, and are careful enough not to break your smart TV's updates or a shop's checkout button. Also use the server's IPv4 address when setting up devices. IPv6 addresses on home networks often change, and if your DNS server's address changes, the whole network goes down with it.

What DNS blocking can and can't do

It's worth being clear about the limits, because this method has one built in.

It works well for smart TVs, phone apps and smart home gadgets. You can't install a browser extension on those, and they send a surprising amount of data about you. It also removes ordinary banner ads on every device in the house, and blocks known and websites for the whole network.

It can't help with YouTube and Twitch, because they send ads from the same domain as the videos. Blocking the ad would block the video. The same is true of sponsored posts mixed into social media feeds. Some devices also have Google's DNS server built in, and ignore yours completely. There are router settings that force them back to your server, but that's another post.

BANNER ADStwo domainsthe site's domaincontentan ad server's domainadsblocked on its own,the page still loadsYOUTUBE, TWITCHone domainthe same domaincontent and adsblock the ad andyou block the video
DNS blocking works on whole domains, so it can only remove ads that come from a domain of their own.

The right way to use it is as a first layer of protection for the whole network, together with a browser extension such as uBlock Origin on the computers that can run one.

Update: a second drive

About a month after the build, I opened the laptop again to use the one part of it that was empty.

The bottom cover comes off in one piece once its screws are out, and everything can be reached from that side: the fan and the copper heat pipe, two memory slots under their instruction stickers, the Wi-Fi card, the 256 GB M.2 (Solid-State Drive) the laptop came with, the small coin battery for the clock, and the 42 Wh main battery.

The laptop with its bottom cover off: fan, heat pipe, memory slots, Wi-Fi card, M.2 SSD, battery and an empty drive bay

The motherboard up close, with the fan, the memory slot stickers and the battery

The inside of the bottom cover, with its copper shielding and foam pads

The part that matters is in the corner next to the battery: an empty space for a 2.5-inch drive. Dell printed four numbered steps for it on the sticker that covers it.

The empty 2.5-inch bay, with Dell's four numbered steps printed on its sticker

The space takes an ordinary 2.5-inch SATA (Serial AT Attachment) drive, so I fitted a 1 TB Crucial MX500.

A Crucial 2.5-inch SSD, still in its bag

The back of the Crucial MX500 1000 GB, a SATA 6 Gb/s drive, with the serial number and PSID blurred

The serial number and the PSID (Physical Security ID) on the label are blurred. The PSID is printed on the drive so that anyone holding it can reset the drive's built-in to factory settings. That's exactly why it shouldn't be posted online.

The SSD fitted in the bay next to the battery, with the memory slot stickers peeled off

One terabyte next to the original 256 GB is about four times the space, on a machine that still cost nothing except the drive.

Where this goes next

The laptop that sat unused in a room now runs Debian. It has a firewall, it can be reached over SSH, it publishes services through a Cloudflare Tunnel, and it blocks ads for every device in the house. It cost nothing but an evening, and most of that evening went into one zombie container.

There are many more things a machine like this can run: a media server, file syncing, home automation, or a private server. Those are future posts.

The lesson from this one is that an old laptop you no longer use can already be a server. It only needs some setup.

Check yourself

3 questions · nothing is saved
  1. 1.You're setting up UFW over SSH. What must you do before running ufw enable?
  2. 2.How does a Cloudflare Tunnel make the server reachable without port forwarding?
  3. 3.Why can't a DNS sinkhole such as AdGuard Home block YouTube ads?

Who wrote this

Author profile and background

Takumi Yamada

Takumi Yamada

· Backend Engineer

Backend engineer building services, databases, Linux tooling, and NEGEN SYSTEMS. Writing about low-level mechanics, distributed systems, and real-world security.

End of post
NEGEN SYSTEMS
Receipt · post 23 of 31
Written
Jun 13, 2026
Length
2,911 words · 13 min
Built
…
Served by
…
Delivered
…
Over the wire
…
Go's share
…
Next up the stack · L3 Networks

How Your Home Network Actually Works

DHCP, ARP, NAT, and the four devices inside your "router": the local half of networking, which happens before a packet ever reaches the internet.

6 min read