A spare-machine Gitea forge, hardened, backed up and with CI, as a template. Personal values are placeholders listed in the README.
133 lines
3.8 KiB
Markdown
133 lines
3.8 KiB
Markdown
---
|
|
type: Guide
|
|
purpose: Make the laptop behave as an always-on server with a fixed LAN address.
|
|
answers:
|
|
- "How does the laptop become an always-on server with a fixed IP?"
|
|
---
|
|
|
|
# 02 — Server First Boot
|
|
|
|
Turn the fresh install into an always-on headless server. Step 1 still runs
|
|
inside the chroot from [01-arch-install.md](01-arch-install.md).
|
|
|
|
## 1. Stop the lid from suspending the server
|
|
|
|
This is a laptop acting as a headless server. systemd's default is to suspend on
|
|
lid close, which takes the whole box off the network.
|
|
|
|
Use a drop-in, not an append to `logind.conf`. The drop-in carries its own
|
|
`[Login]` header, so it cannot land in the wrong section, and a package upgrade
|
|
that rewrites the shipped file leaves it untouched:
|
|
|
|
```bash
|
|
mkdir -p /etc/systemd/logind.conf.d
|
|
cat > /etc/systemd/logind.conf.d/10-lid.conf <<'EOF'
|
|
[Login]
|
|
HandleLidSwitch=ignore
|
|
HandleLidSwitchExternalPower=ignore
|
|
HandleLidSwitchDocked=ignore
|
|
EOF
|
|
```
|
|
|
|
All three keys are needed. `HandleLidSwitch` covers battery only —
|
|
a server that is permanently plugged in follows
|
|
`HandleLidSwitchExternalPower`, so setting just the first one is the common
|
|
way to end up with a box that still suspends.
|
|
|
|
Takes effect on the reboot in step 2. **Verify after that reboot** — this
|
|
setting fails silently, and the symptom (a server that vanishes when the lid is
|
|
shut) looks like a network or power fault:
|
|
|
|
```bash
|
|
systemd-analyze cat-config systemd/logind.conf | grep -i lidswitch
|
|
```
|
|
|
|
Expect the three commented defaults, then your three uncommented overrides
|
|
below them. Overrides win by appearing later. If only commented lines appear,
|
|
the drop-in did not land — likely written outside the chroot.
|
|
|
|
Applying it on an already-running system needs no reboot:
|
|
|
|
```bash
|
|
sudo systemctl restart systemd-logind
|
|
```
|
|
|
|
## 2. Exit and reboot
|
|
|
|
```bash
|
|
exit # leave chroot
|
|
umount -R /mnt
|
|
reboot
|
|
```
|
|
|
|
Remove USB when machine restarts.
|
|
|
|
## 3. First login and network
|
|
|
|
Log in as `admin`. Check network:
|
|
|
|
```bash
|
|
nmcli device status
|
|
# if ethernet not connected:
|
|
nmcli connection up "Wired connection 1"
|
|
```
|
|
|
|
Verify internet: `ping -c 3 archlinux.org`
|
|
|
|
Turn off wifi. A server with two interfaces on the same subnet gets two
|
|
addresses, and the router's port forwards only target one of them:
|
|
|
|
```bash
|
|
nmcli radio wifi off
|
|
```
|
|
|
|
Note the ethernet address and MAC — every later doc depends on them:
|
|
|
|
```bash
|
|
ip -4 addr show # 192.168.1.50
|
|
ip link # note the MAC of the wired interface
|
|
```
|
|
|
|
## 4. Pin the server's IP at the router
|
|
|
|
DHCP will move this address on its own. When it relocates the server, SSH
|
|
breaks and it looks exactly like a dead host. Every
|
|
port forward in [03](03-ssh-hardening.md) and [06](06-docker-deploy.md) fails
|
|
silently the next time it happens.
|
|
|
|
Reserve it at the router — a DHCP reservation is better than a static address on
|
|
the host, because the router then never offers that IP to anything else.
|
|
|
|
*Adapt if yours differs: menu names below are from one TP-Link model.*
|
|
|
|
Browse to the router's admin page (often `http://192.168.1.1`), log in, then:
|
|
|
|
```
|
|
Advanced → Network → DHCP Server → Address Reservation → Add
|
|
MAC Address: <server MAC from ip link>
|
|
IP Address: 192.168.1.50
|
|
```
|
|
|
|
Save, reboot the server, confirm the address held:
|
|
|
|
```bash
|
|
ip -4 addr show
|
|
```
|
|
|
|
While you are in the admin panel, close two defaults that undercut everything
|
|
in [08-firewall.md](08-firewall.md):
|
|
|
|
```
|
|
Advanced → NAT Forwarding → UPnP → disable
|
|
Advanced → System Tools → Administration → Remote Management → disable
|
|
```
|
|
|
|
UPnP lets any device on the LAN open ports through the firewall without asking.
|
|
Remote Management exposes the router's own admin UI to the internet, and on
|
|
port 443 it also collides with the forward Caddy needs in
|
|
[06-docker-deploy.md](06-docker-deploy.md).
|
|
|
|
## Next step
|
|
|
|
Continue with [03-ssh-hardening.md](03-ssh-hardening.md).
|