aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--default.nix2
-rw-r--r--host.nix24
2 files changed, 14 insertions, 12 deletions
diff --git a/default.nix b/default.nix
index fc2d6e0..538c928 100644
--- a/default.nix
+++ b/default.nix
@@ -53,7 +53,7 @@ let
networking.useDHCP = false;
networking.resolvconf.enable = false;
- # The host's resolver, see host.nix.
+ # dnsmasq on the host, see host.nix.
environment.etc."resolv.conf".text = "nameserver 172.16.0.1\n";
systemd.network.enable = true;
systemd.network.wait-online.enable = false;
diff --git a/host.nix b/host.nix
index 8ee0aea..73640c6 100644
--- a/host.nix
+++ b/host.nix
@@ -1,11 +1,11 @@
# Host side of the guests' network: a bridge with tap devices fctap0,
-# fctap1, ... owned by the user running the VMs, a DHCP server, and NAT to
-# the outside world. Each running VM takes one tap device, so taps is the
+# fctap1, ... owned by the user running the VMs, a DHCP server and DNS
+# resolver, and NAT to the outside world. Each running VM takes one tap device, so taps is the
# number of VMs that can run at the same time.
# usage (in the host's configuration.nix):
# imports = [ (import ./host.nix { user = "tv"; }) ];
-# The host's DNS resolver has to answer on 172.16.0.1, and the host's
-# firewall has to let the guests in on fcbr0: DHCP (udp 67) and DNS (53)
+# The host's firewall has to let the guests in on fcbr0: DHCP (udp 67) and
+# DNS (udp and tcp 53)
# as input, and anything from fcbr0 (plus the return traffic) as forward.
{ user, taps ? 8 }: { lib, pkgs, ... }: let
tapNames = map (i: "fctap${toString i}") (lib.range 0 (taps - 1));
@@ -25,25 +25,27 @@ in {
};
# A dnsmasq of its own, so it doesn't get mixed up with one the host might
- # run otherwise. DHCP only (port=0 disables DNS); bind-dynamic copes with
- # fcbr0 not being there yet.
- systemd.services.fcbr0-dhcp = {
+ # run otherwise. It forwards DNS queries to the servers in the host's
+ # /etc/resolv.conf (and answers from its /etc/hosts). It only listens on
+ # fcbr0 (except-interface=lo, else it would also take 127.0.0.1:53 from a
+ # resolver the host runs there); bind-dynamic copes with fcbr0 not being
+ # there yet.
+ systemd.services.fcbr0-dnsmasq = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
- RuntimeDirectory = "fcbr0-dhcp";
+ RuntimeDirectory = "fcbr0-dnsmasq";
Restart = "on-failure";
ExecStart = lib.escapeShellArgs [
"${pkgs.dnsmasq}/bin/dnsmasq"
"--keep-in-foreground"
"--conf-file=/dev/null"
- "--port=0"
"--bind-dynamic"
"--interface=fcbr0"
+ "--except-interface=lo"
"--dhcp-authoritative"
"--dhcp-range=172.16.0.2,172.16.0.254,1h"
- "--dhcp-option=option:dns-server,172.16.0.1"
- "--dhcp-leasefile=/run/fcbr0-dhcp/leases"
+ "--dhcp-leasefile=/run/fcbr0-dnsmasq/leases"
];
};
};