[Nix-dev] How to add an additional IP address besides the DHCP configured address?

Bas van Dijk v.dijk.bas at gmail.com
Wed Feb 18 17:50:29 CET 2015


Hello,

I would like to add the IP address 172.16.48.17/28 to my enp0s3
interface but I would also like to keep the DHCP configured address. I
tried the following:

  networking = {
    interfaces.enp0s3 = {
      useDHCP = true;
      ip4 = [
        { address = "172.16.48.17";
          prefixLength = 28;
        }
      ];
    };
  };

But after a "nixos-rebuild switch" ifconfig doesn't show the additional address:

$ ifconfig enp0s3
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.42.225  netmask 255.255.255.0  broadcast 192.168.42.255
        inet6 fdf1:4004:db11:1:a00:27ff:fe34:fdef  prefixlen 64
scopeid 0x0<global>
        inet6 fe80::a00:27ff:fe34:fdef  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:34:fd:ef  txqueuelen 1000  (Ethernet)
        RX packets 214736  bytes 67482409 (64.3 MiB)
        RX errors 14  dropped 0  overruns 0  frame 0
        TX packets 46641  bytes 7880848 (7.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  base 0xd020

Is this possible or should I use networking.localCommands?

Cheers,

Bas


More information about the nix-dev mailing list