Skip to content

Replacing the colo router with a container (or two)

After working through the complexities of using headscale/tailscale I realized that I really only needed the colo router to do 2 things.

  1. Provide us access to the admin lan (the servers and their remote consoles).

    graph LR
    D([])<-->A[Host interface]
    D<-->E[Host Drac/ILO]
    C[laptop] <-- Wireguard --> B(homer/virgil);
    B <-- Wireguard -->D;
  2. Allow the servers to reach the update repositories.

    graph LR
    B --> I([internet])
    A[Host] -- Apt Via Proxy --> B(homer/virgil);

By using a container (or two) with access to both the external lan and the admin lan we can set up wireguard and squid. Wireguard allows us to securely connect to the admin lan while squid allows the servers a mechanism to recieve software updates.


root@aoc2024:~# lxc init ubuntu:22.04 homer -c security.privileged=true -p susdev23 -p infra
root@aoc2024:~# lxc config edit homer
name: homer
description: "wireguard/squid host"
    name: eth1
    nictype: bridged
    parent: br3
    type: nic
root@aoc2024:~# lxc start homer
root@aoc2024:~# lxc exec homer bash
root@homer:~# nano /etc/netplan/50-cloud-init.yaml
    version: 2
            -   to: default
root@homer:~# netplan apply

Backcheck the interfaces

root@homer:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
       valid_lft forever preferred_lft forever
45: eth0@if46: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:ba:f0:be brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet brd scope global eth0
       valid_lft forever preferred_lft forever
47: eth1@if48: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:2e:6f:d8 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet brd scope global eth1
       valid_lft forever preferred_lft forever

Install prerequisites and enable ip forwarding

The next few sections are done on the gateway container (homer)

apt install wireguard
apt install resolvconf
sysctl -w net.ipv4.ip_forward=1

Clone it

lxc snapshot aoc2024:homer 19jun24
lxc copy aoc2024:homer/19jun24 virgil
lxc config edit virgil


Set up wireguard

cd /etc/wireguard/
wg genkey | sudo tee private.key
chmod go= private.key
cat private.key | wg pubkey | sudo tee public.key
wg genpsk |tee preshared.psk
nano /etc/wireguard/wg0.conf
# wg0.conf
Address =
ListenPort = 1194
PrivateKey = <<contents of private.key>>
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth1 -j MASQUERADE

# merlot
PublicKey = <<contents of public.key>>
AllowedIPs =,
PresharedKey = <<contents of preshared.key>>

# amyl dons laptop
PublicKey = <<key from wireguard client>>
AllowedIPs =
PresharedKey = <<contents of preshared.key>>

Enable it

wg-quick up wg0
systemctl enable wg-quick@wg0

~~Squid proxy for main servers~~

As of this week the latest update to squid completely overwrote the working configuration file without even making a backup copy. Can you say exposure and disfunction? FRACK THAT. IT'S GONE.

root@virgil:/etc/squid# apt remove --purge squid

Tiny Proxy

Setting up TinyProxy

This is on virgil (x.x.x.228) repeat this on homer (x.x.x.227)

apt install tinyproxy -y
systemctl enable tinyproxy
cd /etc/tinyproxy/
cp tinyproxy.conf tinyproxy.conf.noisy
grep -v "^\#" tinyproxy.conf.noisy |grep -v "^$" >tinyproxy.conf
nano tinyproxy.conf
User tinyproxy
Group tinyproxy
Port 3128
Timeout 600
DefaultErrorFile "/usr/share/tinyproxy/default.html"
StatFile "/usr/share/tinyproxy/stats.html"
LogLevel Info
PidFile "/run/tinyproxy/"
MaxClients 10
ViaProxyName "tinyproxy"
systemctl enable tinyproxy
systemctl start tinyproxy

Test the proxy

root@kb2018:~# curl -x
<title>301 Moved Permanently</title>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="">here</a>.</p>
<address>Apache/2.4.52 (Ubuntu) Server at Port 80</address>

Set up apt to use proxy

nano /etc/apt/apt.conf.d/00proxy.conf
Acquire::http::Proxy "";

Test apt through proxy

root@aoc2024:/etc/apt/apt.conf.d# ip route delete default
root@aoc2024:/etc/apt/apt.conf.d# ip route dev br3 proto kernel scope link src
root@aoc2024:/etc/apt/apt.conf.d# apt update
Hit:1 noble InRelease
Get:2 noble InRelease
Hit:3 noble-updates InRelease
Hit:4 noble-security InRelease
Hit:5 noble-backports InRelease
Fetched 6575 B in 1s (9357 B/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.

References / Linkdump

Rehome this pile

nano /etc/squid/squid.conf
# -------------------------------------------------------/etc/squid/squid.conf
acl localnet src  # RFC 1918 local private network (LAN)
acl SSL_ports port 443
acl Safe_ports port 80  # http
acl Safe_ports port 21  # ftp
acl Safe_ports port 443  # https
acl Safe_ports port 70  # gopher
acl Safe_ports port 210  # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280  # http-mgmt
acl Safe_ports port 488  # gss-http
acl Safe_ports port 591  # filemaker
acl Safe_ports port 777  # multiling http
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
include /etc/squid/conf.d/*
http_access allow localhost
http_access allow localnet
http_access deny all
http_port 3128
coredump_dir /var/spool/squid
refresh_pattern ^ftp:  1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern \/(Packages|Sources)(|\.bz2|\.gz|\.xz)$ 0 0% 0 refresh-ims
refresh_pattern \/Release(|\.gpg)$ 0 0% 0 refresh-ims
refresh_pattern \/InRelease$ 0 0% 0 refresh-ims
refresh_pattern \/(Translation-.*)(|\.bz2|\.gz|\.xz)$ 0 0% 0 refresh-ims
refresh_pattern .  0 20% 4320

Enable it

systemctl enable squid
systemctl start squid