Networking: Difference between revisions

imported>Onny
Add section on static ip configuration
imported>Hypnosis2839
VLAN's: rename section, also usePredictableInterfaceNames was meant for backwards compat
Line 100: Line 100:
</syntaxhighlight>
</syntaxhighlight>


== VLAN's ==
== VLANs ==


[https://nixos.org/manual/nixos/stable/options.html#opt-networking.vlans vlan information in the manual]
Refer to [https://nixos.org/manual/nixos/stable/options.html#opt-networking.vlans {{ic|networking.vlans}} in the manual].


The below is a complete networking example, showing 2 interfaces, 1 with VLAN trunk tagging and 1 without.
Below is a complete networking example showing two interfaces, one with VLAN trunk tagging and one without.


eth1 is a normal network interface @ 192.168.1.2, with no VLAN information.
{{ic|enp2s1}} is a normal network interface at {{ic|192.168.1.2}} with no VLAN information.


eth0 is the vlan trunk tagged, with 2 VLAN's tagged, vlan 100 and vlan 101.
{{ic|enp2s0}} is the virtual LAN trunk, with two tagged VLANs, {{ic|vlan100}} and {{ic|vlan101}}.
 
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.


{{ic|vlan100}} is in the {{ic|10.1.1.X}} network and {{ic|vlan101}} is in the {{ic|10.10.10.X}} network.


The {{ic|hostID}} should be unique among your machines, [https://nixos.org/manual/nixos/stable/options.html#opt-networking.hostId as mentioned in the manual].


Complete networking section example:
Complete networking section example:
Line 124: Line 122:
       domain = "example.com";
       domain = "example.com";
       dhcpcd.enable = false;
       dhcpcd.enable = false;
      usePredictableInterfaceNames = false;
       interfaces.enp2s1.ipv4.addresses = [{
       interfaces.eth1.ipv4.addresses = [{
         address = "192.168.1.2";
         address = "192.168.1.2";
         prefixLength = 28;
         prefixLength = 28;
       }];
       }];
       vlans = {
       vlans = {
         vlan100 = { id=100; interface="eth0"; };
         vlan100 = { id=100; interface="enp2s0"; };
         vlan101 = { id=101; interface="eth0"; };
         vlan101 = { id=101; interface="enp2s0"; };
       };
       };
       interfaces.vlan100.ipv4.addresses = [{
       interfaces.vlan100.ipv4.addresses = [{