From 81d801d5cdfb84d6186832412d560a6428aaaec1 Mon Sep 17 00:00:00 2001 From: Ville Ilvonen Date: Mon, 29 Apr 2024 15:06:01 +0300 Subject: [PATCH] networking: module for static names * based on decisions to use static names over internal DNS https://github.com/tiiuae/ghaf/pull/427 * removes dnsmasq and dhcp from net-vm to other guests * WIP: static IPs not assigned to other guests yet Signed-off-by: Ville Ilvonen --- modules/common/default.nix | 1 + modules/common/networking/default.nix | 7 ++++++ modules/common/networking/hosts.nix | 21 ++++++++++++++++ .../microvm/virtualization/microvm/netvm.nix | 24 +------------------ 4 files changed, 30 insertions(+), 23 deletions(-) create mode 100644 modules/common/networking/default.nix create mode 100644 modules/common/networking/hosts.nix diff --git a/modules/common/default.nix b/modules/common/default.nix index 159bd3a96..2db35980d 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -17,5 +17,6 @@ ./version ./virtualization/docker.nix ./systemd + ./networking ]; } diff --git a/modules/common/networking/default.nix b/modules/common/networking/default.nix new file mode 100644 index 000000000..1aecb04ce --- /dev/null +++ b/modules/common/networking/default.nix @@ -0,0 +1,7 @@ +# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors +# SPDX-License-Identifier: Apache-2.0 +{ + imports = [ + ./hosts.nix + ]; +} diff --git a/modules/common/networking/hosts.nix b/modules/common/networking/hosts.nix new file mode 100644 index 000000000..580f21012 --- /dev/null +++ b/modules/common/networking/hosts.nix @@ -0,0 +1,21 @@ +# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors +# SPDX-License-Identifier: Apache-2.0 +{lib, ...}: { + environment.etc.hosts = lib.mkForce { + # please note that .100. network is not + # reachable from ghaf-host. It's only reachable + # guest-to-guest. Use to .101. (debug) to access + # guests from host (no names) + text = '' + 127.0.0.1 localhost + 192.168.100.1 net-vm + 192.168.100.2 log-vm + 192.168.100.3 gala-vm + 192.168.100.4 chromium-vm + 192.168.100.5 zathura-vm + 192.168.100.6 element-vm + 192.168.100.7 gui-vm + ''; + mode = "0444"; + }; +} diff --git a/modules/microvm/virtualization/microvm/netvm.nix b/modules/microvm/virtualization/microvm/netvm.nix index bfdc6d458..f8f06d30c 100644 --- a/modules/microvm/virtualization/microvm/netvm.nix +++ b/modules/microvm/virtualization/microvm/netvm.nix @@ -51,29 +51,7 @@ # Add simple wi-fi connection helper environment.systemPackages = lib.mkIf config.ghaf.profiles.debug.enable [pkgs.wifi-connector]; - # Dnsmasq is used as a DHCP/DNS server inside the NetVM - services.dnsmasq = { - enable = true; - resolveLocalQueries = true; - settings = { - server = ["8.8.8.8"]; - dhcp-range = ["192.168.100.2,192.168.100.254"]; - dhcp-sequential-ip = true; - dhcp-authoritative = true; - domain = "ghaf"; - listen-address = ["127.0.0.1,192.168.100.1"]; - dhcp-option = [ - "option:router,192.168.100.1" - "6,192.168.100.1" - ]; - expand-hosts = true; - domain-needed = true; - bogus-priv = true; - }; - }; - - # Disable resolved since we are using Dnsmasq - services.resolved.enable = false; + services.resolved.enable = true; systemd.network = { enable = true;