unit/modules/networking.nix

51 lines
917 B
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 = {
interfaces.eth0 = {
useDHCP = false;
addresses = {
address = "10.0.1.3";
prefixLength = 24;
};
};
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
];
extraCommands = ''
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
'';
2021-02-08 13:42:35 +01:00
};
}