Add contabo wan for ipv6 support

This commit is contained in:
Lillian Violet 2024-03-02 23:15:23 +01:00
parent a2c50346f0
commit ad4a70ffa1
5 changed files with 95 additions and 0 deletions

View file

@ -95,6 +95,13 @@
# Other options beside 'alejandra' include 'nixpkgs-fmt' # Other options beside 'alejandra' include 'nixpkgs-fmt'
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
# Reusable nixos modules you might want to export
# These are usually stuff you would upstream into nixpkgs
nixosModules = import ./modules/nixos;
# Reusable home-manager modules you might want to export
# These are usually stuff you would upstream into home-manager
homeManagerModules = import ./modules/home-manager;
# Your custom packages and modifications, exported as overlays # Your custom packages and modifications, exported as overlays
overlays = import ./overlays {inherit inputs;}; overlays = import ./overlays {inherit inputs;};

View file

@ -0,0 +1,5 @@
# Add your reusable NixOS modules to this directory, on their own file (https://nixos.wiki/wiki/Module).
# These should be stuff you would like to share with others, not your personal configurations.
{
# List your module files here
}

View file

@ -0,0 +1,65 @@
{
lib,
config,
...
}:
with lib; let
cfg = config.modules.contabo.wan;
in {
options.modules.contabo.wan = {
enable = mkEnableOption "Enable Contabo Cloud WAN interface configuration";
macAddress = mkOption {
type = types.str;
description = "MAC Address of the WAN interface";
};
ipAddresses = mkOption {
type = types.listOf types.str;
description = "List of IP Addresses on the WAN interface";
};
};
config = mkIf cfg.enable {
systemd.network.networks."20-wan" = {
matchConfig = {
MACAddress = cfg.macAddress;
};
address = cfg.ipAddresses;
routes = [
{routeConfig.Gateway = "fe80::1";}
{routeConfig = {Destination = "172.31.1.1";};}
{
routeConfig = {
Gateway = "172.31.1.1";
GatewayOnLink = true;
};
}
{
routeConfig = {
Destination = "172.16.0.0/12";
Type = "unreachable";
};
}
{
routeConfig = {
Destination = "192.168.0.0/16";
Type = "unreachable";
};
}
{
routeConfig = {
Destination = "10.0.0.0/8";
Type = "unreachable";
};
}
{
routeConfig = {
Destination = "fc00::/7";
Type = "unreachable";
};
}
];
};
};
}

View file

@ -0,0 +1,6 @@
# Add your reusable NixOS modules to this directory, on their own file (https://nixos.wiki/wiki/Module).
# These should be stuff you would like to share with others, not your personal configurations.
{
# List your module files here
contabo.wan = import ./contabo/wan;
}

View file

@ -10,6 +10,7 @@
imports = [ imports = [
# If you want to use modules your own flake exports (from modules/home-manager): # If you want to use modules your own flake exports (from modules/home-manager):
# outputs.homeManagerModules.example # outputs.homeManagerModules.example
outputs.nixosModules.contabo.wan
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
# Or modules exported from other flakes (such as nix-colors): # Or modules exported from other flakes (such as nix-colors):
# inputs.nix-colors.homeManagerModules.default # inputs.nix-colors.homeManagerModules.default
@ -121,6 +122,17 @@
networking.firewall.allowedTCPPorts = [22 80 443]; networking.firewall.allowedTCPPorts = [22 80 443];
networking.useNetworkd = true;
modules.contabo.wan = {
enable = true;
macAddress = "aa:bb:cc:dd:ee:ff"; # changeme
ipAddresses = [
"192.0.2.0/32"
"2001:db8::1/64"
];
};
# Set your time zone. # Set your time zone.
time.timeZone = "Europe/Amsterdam"; time.timeZone = "Europe/Amsterdam";