unit/modules/networking.nix

73 lines
1.3 KiB
Nix
Raw Normal View History

2021-02-08 13:42:35 +01:00
{ config, lib, pkgs, ... }:
{
2021-03-12 12:06:26 +01:00
# Assign a static IP
networking = {
2021-03-15 10:40:49 +01:00
hostName = "unit";
hostId = "737d82f4";
2021-03-12 12:06:26 +01:00
interfaces.eth0 = {
useDHCP = false;
2021-03-15 10:40:49 +01:00
ipv4.addresses = [{
2021-03-12 12:06:26 +01:00
address = "10.0.1.3";
prefixLength = 24;
2021-03-15 10:40:49 +01:00
}];
2021-03-12 12:06:26 +01:00
};
defaultGateway = {
address = "10.0.1.1";
interface = "eth0";
};
nameservers = [ "1.1.1.1" "8.8.8.8" ];
enableIPv6 = false;
};
2021-02-08 13:42:35 +01:00
# Enable zeroconf
services.avahi = {
enable = true;
nssmdns = true;
publish = {
enable = true;
userServices = true;
domain = true;
workstation = true;
};
reflector = true;
};
# Firewall configuration
networking.firewall = {
2021-03-12 12:06:26 +01:00
allowedTCPPorts = [
445 # Samba
139 # Samba
];
allowedUDPPorts = [
137 # Samba
138 # Samba
1194 # Wireguard
];
2021-02-08 13:42:35 +01:00
};
2021-03-12 12:08:22 +01:00
# Enable NAT for wireguard
networking.nat = {
enable = true;
externalInterface = "eth0";
internalInterfaces = [ "wg0" ];
};
# Wireguard setup
networking.wireguard.interfaces = {
wg0 = {
ips = [ "10.9.0.1/24" ];
listenPort = 1194;
privateKeyFile = "/home/coace/.wg/keys/privatekey";
peers = [
2021-03-12 12:43:22 +01:00
# Amin
2021-03-12 12:08:22 +01:00
{
publicKey = "XMkTztU2Y8hw6Fu/2o4Gszij+EmNacvFMXuZyHS1n38=";
allowedIPs = [ "10.9.0.2/32" ];
}
];
};
};
2021-02-08 13:42:35 +01:00
}