Nixos tests: What are the ip's of created nodes?

Hi!

Excuse the cryptic title. I have a basic scenario to test with nixos tests: one node runs a server, second node calls the server. How do I refer to the server node from within the client node? Anything like an ip address or sth dns resolves could work.

I’ve seen examples of tests with endpoints like:

http://machine1/

and I’ve seen sometimes some use of nginx like:

    services.nginx = {
      enable = true;
      virtualHosts."machine1" = {};
    };

BUT

  • my communication is not via http but some custom protocol
  • I couldn’t get anything blindly similar to the examples to work for me.
  • I don’t get the whole setup, I’m moving blind. What does this nginx line do? Is it crucially needed? Is there some networking/dns setup created by default in the nixos tests? Are there docs?

Here’s my need reiterated in a form of a pseudocode:

nodes = {  # in nixos test
  block_producer = {
    networking.firewall = {
      enable = true;
      allowedTCPPorts = [ 3001 ];
    };
    services.server = {
      port = 3001;
    };
  };
  relay_node = {
    services.client = {
      serverAddr = {
        address = "< ??? >";
        port = 3001;
      };
    };
  };
};

Thanks!

You can use a static IP and it will work, there’s just a dumb DHCP running over there.

1 Like

For a more advanced example you can take a look at the bird test in nixpkgs, it makes two bird hosts peer with each other. The nginx line doesn’t really do anything except for opening http on port 80.

1 Like

Alright, thanks guys. Now need to figure out how to define a static ip. The bird test will be needed.