| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
| |
egress.lua goes along. The host now imports it as
(import .../modules/host { user = ...; }).
|
| |
|
|
|
| |
So default.nix (or shell.nix, flake.nix) at the top can become something
else. kernel.nix goes along, as it's only an argument of the runner.
|
| |
|
|
|
|
|
|
|
| |
Nothing got forwarded, but the host itself was wide open to the guests:
its own services (sshd, ...) at 172.16.0.1, where DNS sends every name,
or any of its other addresses, and ICMP. Now the input chain rejects
everything from fcbr0 but DHCP and DNS to dnsmasq and the redirected TLS
to nginx. And a bridge table drops frames between the taps, so the
guests can't talk to each other either.
|
| |
|
|
|
|
|
| |
github.com's response headers are bigger than nginx's default buffer
for them, so requests got a 502 ("upstream sent too big header"). Give
them 64k. Also remove a stale decrypt.sock before starting, else nginx
can't bind to it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
OpenResty replaces the plain nginx SNI proxy, and egress.lua decides by
server name and the rules in /var/lib/fc-egress/allowed: DOMAIN passes
the domain and its subdomains through without decrypting; DOMAIN/PREFIX
decrypts, with certificates made on the fly from the host's own CA, and
only forwards requests whose path starts with PREFIX. Upstream is
always port 443 of the server name, as resolved by the host, and its
certificate gets verified. The rules get read on every connection, so
the path unit and reloads are gone.
The CA certificate gets published as /var/lib/fcbr0-egress/ca.pem, and
the guest trusts it when built on the host.
|
| |
|
|
|
|
|
| |
The host's own web server listens on 0.0.0.0:443, which keeps nginx from
binding to 172.16.0.1:443. nginx now listens on 172.16.0.1:proxyPort
(default 10443), and nftables redirects the guests' tcp port 443 there,
whatever address they connect to.
|
| |
|
|
|
|
|
|
| |
With networkd, fcbr0 only got its address while it had carrier, i.e.
while a VM was running, so nginx failed with "bind() to 172.16.0.1:443
failed (99: Cannot assign requested address)" and gave up after a few
restarts. Configure fcbr0 without carrier, and let nginx retry without
start limit until the address is there.
|
| |
|
|
|
|
|
|
|
| |
The guests' DNS now resolves every name to 172.16.0.1, where nginx reads
the server name from the TLS ClientHello and, if it's allowed, connects
to port 443 of that name as resolved by the host. The guests need no
proxy settings any more, and a faked server name can't get them to any
other address. fc-egress keeps managing the list (now plain domains),
and a reload regenerates nginx's map from it.
|
| |
|
|
|
|
|
|
|
|
|
| |
Instead of forwarding to addresses dnsmasq resolved for allowed names,
nothing gets forwarded from fcbr0 any more (and no NAT). The guests use
squid on 172.16.0.1:3128 as their proxy, which only allows CONNECT to
port 443 of the domains in /var/lib/fc-egress/allowed. That list can be
changed at any time with fc-egress (list, allow, deny, log); a path unit
makes squid re-read it. DNS answers NXDOMAIN for everything.
host.nix no longer takes allowedDomains.
|
| |
|
|
|
|
|
|
|
|
| |
host.nix takes allowedDomains (default none). The guests' dnsmasq only
resolves those names and their subdomains, answers NXDOMAIN for anything
else, and adds the addresses it resolves to an nftables set. The new
table inet firecracker rejects everything from fcbr0 except tcp port 443
to addresses in that set. dnsmasq runs without cache, so it refills the
set after an nftables reload, and without AAAA records, as the guests
only have IPv4.
|
| |
|
|
|
|
| |
It forwards to the servers in the host's resolv.conf and listens only on
fcbr0, so it doesn't get in the way of a resolver on the host's loopback.
The service is renamed from fcbr0-dhcp to fcbr0-dnsmasq.
|
| |
|
|
|
| |
The guest's resolv.conf and the DHCP server now point at 172.16.0.1, so
the host's resolver has to answer there.
|
| |
|
|
|
|
|
|
|
|
| |
host.nix now makes a bridge fcbr0 with a number of tap devices (default 8)
and runs a dnsmasq of its own for DHCP. The run script takes the first
tap device it can lock and derives the guest MAC from its number. The
guest uses DHCP, with the MAC as client identifier, as the machine-id
(and thus the default DUID) is the same in every VM.
host.nix now takes { user, taps ? 8 } instead of just the user.
|
|
|
Give the guest a virtio-net interface backed by the host tap device
fctap0, with a static address (172.16.0.2/24, gateway 172.16.0.1) set up
by systemd-networkd, and 9.9.9.9 as nameserver.
host.nix is a NixOS module for the host that creates fctap0, owned by
the given user, and NATs it:
imports = [ (import ./host.nix "tv") ];
Firecracker refuses to start if fctap0 doesn't exist.
|