1
0
Fork 0
mirror of https://github.com/mdlayher/homelab.git synced 2024-12-14 11:47:32 +00:00

nixos: add network infrastructure to hosts

This commit is contained in:
Matt Layher 2020-01-24 11:36:50 -05:00
parent dd605c4955
commit d72df0d9d5
4 changed files with 49 additions and 38 deletions

View file

@ -59,16 +59,16 @@ in {
${lan0.ipv6.ula} routnerr-2.${domain}
${
# Write out internal DNS records for each of the configured hosts.
# If the host does not have an IPv6 ULA address, omit it.
lib.concatMapStrings (host: ''
${host.ipv4} ${host.name}.${domain}
${host.ipv6.ula} ${host.name}.${domain}
'') vars.hosts.servers
${host.ipv4} ${host.name}.${domain}
${if host.ipv6.ula != "" then ''
${host.ipv6.ula} ${host.name}.${domain}
'' else
""}
'') (vars.hosts.servers ++ vars.hosts.infra)
}
192.168.1.2 switch-livingroom01.${domain}
192.168.1.3 switch-office01.${domain}
192.168.1.5 ap-livingroom01.${domain}
192.168.1.8 hdhomerun.${domain}
}
}
'';

View file

@ -8,39 +8,19 @@ let
lab0 = vars.interfaces.lab0;
lan0 = vars.interfaces.lan0;
# Produces a compatible object for the dhcpd4 machines array.
mkHost = (host: {
hostName = host.name;
ethernetAddress = host.mac;
ipAddress = host.ipv4;
});
in {
services.dhcpd4 = {
interfaces =
[ "${lan0.name}" "${guest0.name}" "${iot0.name}" "${lab0.name}" ];
enable = true;
machines = [
{
hostName = "switch-livingroom01";
ethernetAddress = "f0:9f:c2:0b:28:ca";
ipAddress = "192.168.1.2";
}
{
hostName = "switch-office01";
ethernetAddress = "f0:9f:c2:ce:7e:e1";
ipAddress = "192.168.1.3";
}
{
hostName = "ap-livingroom01";
ethernetAddress = "44:d9:e7:02:2a:56";
ipAddress = "192.168.1.5";
}
{
hostName = "hdhomerun";
ethernetAddress = "00:18:dd:32:52:c0";
ipAddress = "192.168.1.8";
}
] ++ lib.forEach vars.hosts.servers (host:
{
hostName = host.name;
ethernetAddress = host.mac;
ipAddress = host.ipv4;
}
);
machines = lib.forEach (vars.hosts.infra ++ vars.hosts.servers) mkHost;
extraConfig = ''
ddns-update-style none;

View file

@ -263,7 +263,10 @@ in {
# SSH for internal machines.
ip6 daddr {
${lib.concatMapStrings (host: "${host.ipv6.gua}, ") vars.hosts.servers}
${
lib.concatMapStrings (host: "${host.ipv6.gua}, ")
vars.hosts.servers
}
} tcp dport ${ports.ssh} counter accept comment "IPv6 SSH"
# Plex running on server.

View file

@ -3,7 +3,7 @@ let
server_ipv4 = "192.168.1.4";
server_ipv6 = "2600:6c4a:787f:d100:4cb:90ff:fe4d:a259";
# Configuration variables which are used to build out configs elsewhere.
# Configuration variables which are used to build out configs elsewhere.
in {
server_ipv4 = server_ipv4;
server_ipv6 = server_ipv6;
@ -40,6 +40,34 @@ in {
mac = "06:cb:90:4d:a2:59";
}
];
# Machines which are considered network infrastructure and not exposed
# externally.
infra = [
{
name = "switch-livingroom01";
ipv4 = "192.168.1.2";
ipv6.ula = "fd9e:1a04:f01d:0:f29f:c2ff:fe0b:28ca";
mac = "f0:9f:c2:0b:28:ca";
}
{
name = "switch-office01";
ipv4 = "192.168.1.3";
ipv6.ula = "fd9e:1a04:f01d:0:f29f:c2ff:fece:7ee1";
mac = "f0:9f:c2:ce:7e:e1";
}
{
name = "ap-livingroom01";
ipv4 = "192.168.1.5";
ipv6.ula = "fd9e:1a04:f01d::46d9:e7ff:fe02:2a56";
mac = "44:d9:e7:02:2a:56";
}
{
name = "hdhomerun";
ipv4 = "192.168.1.8";
ipv6.ula = ""; # No IPv6 support unfortunately.
mac = "00:18:dd:32:52:c0";
}
];
};
interfaces = {
wan0 = {