Change DNS and IP settings

Hi!

New to Nixos.

I have set up a VM to play before going bare metal. For now, I can’t even go through first steps…

  • The OS was setup as a Proxmox VM with a minimal ISO installation.
  • The actual IP Address works and reaches the gateway. We have some network policies that locks everything from accessing the internet. Current Nixos IP is blocked.
  • I try to change the IP to an authorized one (see screenshot) and DNS doe snot work.

It looks like it is trying to download some packages before changing the IP address:

The configuration we try to apply is quite simple:

1

And the new IP has been tested on a similar VM (Debian) and works fine, it is not a networking issue.

Maybe there is something I am missing?

Regards.

Ok, what was the step (or the command)?

Options:

I had a similar issue. The problem is that to update or change the configuration, you have to have a connection available to github. This usually happens if you are disabling or installing any software. There are ways around it but I didn’t figure it out. The solution I found was to use NetworkManager.
Step 1. Configure the IP’s you need in NM via ‘nmtui’ or the GUI app. Once your IP configuration is working properly and you can get to the internet using NM.
Step 2. Run ‘nm2nix’ and copy the config. I created a network.nix config for each computer I manage. I only have 3 so not a big deal. If you have more, you may need to automate this. I’m using flakes so your mileage may vary with your config. Basically import the network.nix from your main config.nix when you run nixos-rebuild…
Step 3. Reboot to verify that your config sticks and you are still able to get to the internet.

An added benefit of doing it this way is that you can now go in to NM and change/delete/modify the network interface and when you reboot, it should go back to whatever you declared in your network.nix file.

Here is a sample of what mine looks like:

{ config, lib, pkgs, modulesPath, ... }:

{
  # TODO Network change for each PC
  networking.networkmanager.enable = true;
  networking.hostName = "mynix1"; # Define your hostname.
  networking.networkmanager.ensureProfiles.profiles = { 
    ethPort = {
      connection = {
        id = "ethPort";
        uuid = "e0a61b63-5555-5555-5555-55555de1620c";
        type = "ethernet";
        autoconnect-priority = "-999";
        interface-name = "enp7s0";
        timestamp = "1714525092";
      };
      ethernet = {
      };
      ipv4 = {
        address1 = "192.168.2.51/16,192.168.1.1";
        dns = "1.1.1.1;192.168.1.1;";
        method = "manual";
      };
      ipv6 = {
        addr-gen-mode = "default";
        address1 = "fd26:55::251/64";
        method = "manual";
      };
      proxy = {
      };
    };
  };
 }

let me try this and I will get back here. Thanks!