Search code examples
network-programmingnixnixos

How to disable networking traffic / connections in Nix language in Nixos?


Have searched https://nixos.org/nixos/options.html#networking for networking options. And I have not found something that may achieve this:

I would like a configuration which ensures that users don't have any network traffic. As it would be a nix generation, running $ nixos-rebuild switch on a configuration.nix file without this network option, could put the computer network communication back to normal.

I have tried mannually calling $ sudo systemctl stop network-manager, but it had no results.

Similarily, nothing seemed to change when I tried modifying this in configuration.nix and then $ nixos-rebuild switch

networking.networkManager.enable = false

Any idea ? Should I manually deal with each of the network interfaces ?


Solution

  • With everything else at defaults, this may be as simple as:

    networking.useDHCP = false;
    networking.interfaces = {};
    

    Of course, you could also go more heavy-handed -- putting all your network hardware into the blacklistedKernelModules list, f/e -- and personally, I'd recommend that.