Networking: Difference between revisions

imported>Averelld
mNo edit summary
imported>Zie
add vlan information.
Line 41: Line 41:
   cp ${pkgs.writeText "duid" "<ID>"} /var/db/dhcpcd/duid
   cp ${pkgs.writeText "duid" "<ID>"} /var/db/dhcpcd/duid
'';
'';
</syntaxhighlight>
== VLAN's ==
The below is a complete networking example, showing 2 interfaces, 1 with VLAN trunk tagging and 1 without.
eth1 is a normal network interface @ 192.168.1.2, with no VLAN information.
eth0 is the vlan trunk tagged, with 2 VLAN's tagged, vlan 100 and vlan 101.
vlan100 is in the 10.1.1.X network and vlan 101 is in the 10.10.10.X network.
the hostID should be random data, derived from something like: <syntaxhighlight>head -c4 /dev/urandom | od -A none -t x4</syntaxhighlight> see [https://nixos.org/manual/nixos/stable/options.html#opt-networking.hostId the manual] for more information.
Complete networking section example:
<syntaxhighlight>
    networking = {
    hostId = "deadb33f";
    hostName = "nixos";
      domain = "example.com";
      dhcpcd.enable = false;
      usePredictableInterfaceNames = false;
      interfaces.eth1.ipv4.addresses = [{
        address = "192.168.1.2";
        prefixLength = 28;
      }];
    vlans = {
    vlan100 = { id=100; interface="eth0"; };
    vlan101 = { id=101; interface="eth0"; };
  };
      interfaces.vlan100.ipv4.addresses = [{
        address = "10.1.1.2";
        prefixLength = 24;
      }];
      interfaces.vlan101.ipv4.addresses = [{
        address = "10.10.10.3";
        prefixLength = 24;
      }];
      defaultGateway = "192.168.1.1
      nameservers = [ "1.1.1.1" "8.8.8.8" ];
    };
</syntaxhighlight>
</syntaxhighlight>