From 008a51702a56b69fe2359561bd9af46b8861b3c5 Mon Sep 17 00:00:00 2001
From: clerie <git@clerie.de>
Date: Sun, 1 Aug 2021 13:32:48 +0200
Subject: [PATCH] Change to new networking setup and add guest network

---
 hosts/carbon/configuration.nix | 44 ++++++++++++++++++++++++++--------
 1 file changed, 34 insertions(+), 10 deletions(-)

diff --git a/hosts/carbon/configuration.nix b/hosts/carbon/configuration.nix
index 66075e8..27d7041 100644
--- a/hosts/carbon/configuration.nix
+++ b/hosts/carbon/configuration.nix
@@ -32,23 +32,47 @@
     { address = "10.152.0.1"; prefixLength = 32; } # Anycast
   ];
   # Network
-  ## Uplink
-  networking.interfaces.enp1s0.useDHCP = true;
-  ## Local Network
-  networking.interfaces.enp2s0.ipv6.addresses = [
+  ## DSL-Uplink
+  networking.vlans."enp1s0.101" = {
+    id = 101;
+    interface = "enp1s0";
+  };
+  ## LTE-Uplink
+  networking.vlans."enp1s0.102" = {
+    id = 102;
+    interface = "enp1s0";
+  };
+  networking.interfaces."enp1s0.102".useDHCP = true;
+  ## Heimnetz
+  networking.vlans."enp1s0.201" = {
+    id = 201;
+    interface = "enp1s0";
+  };
+  networking.interfaces."enp1s0.201".ipv6.addresses = [
     { address = "fd00:152:152:4::1"; prefixLength = 64; }
     { address = "2a01:4f8:1c0c:8221::1"; prefixLength = 64; } # public IPs for local network
   ];
-  networking.interfaces.enp2s0.ipv4.addresses = [
+  networking.interfaces."enp1s0.201".ipv4.addresses = [
     { address = "10.152.4.1"; prefixLength = 24; }
   ];
+  ## Gastnetz
+  networking.vlans."enp1s0.202" = {
+    id = 202;
+    interface = "enp1s0";
+  };
+  networking.interfaces."enp1s0.202".ipv6.addresses = [
+    { address = "fd00:3214:9453:4920::1"; prefixLength = 64; }
+  ];
+  networking.interfaces."enp1s0.202".ipv4.addresses = [
+    { address = "192.168.32.1"; prefixLength = 24; }
+  ];
 
   networking.nat = {
     enableIPv6 = true;
     enable = true;
-    externalInterface = "enp1s0";
-    internalIPv6s = [ "fd00:152:152::/48" ];
-    internalIPs = [ "10.152.0.0/16" ];
+    externalInterface = "enp1s0.102";
+    internalIPv6s = [ "fd00:152:152::/48" "fd00:3214:9453:4920::/64"];
+    internalIPs = [ "10.152.0.0/16" "192.168.32.0/24" ];
   };
 
   networking.wireguard.enable = true;
@@ -175,8 +199,8 @@
     };
   }
 
-  protocol direct direct_enp2s0 {
-    interface "enp2s0";
+  protocol direct direct_enp1s0_201 {
+    interface "enp1s0.201";
     ipv6 {
       table ospf6;
     };