Assign static IP to server

This commit is contained in:
coolneng 2021-03-12 12:06:26 +01:00
parent 1d3d84f871
commit 20b73b364c
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
1 changed files with 29 additions and 5 deletions

View File

@ -1,6 +1,23 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ {
# 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;
};
# Enable zeroconf # Enable zeroconf
services.avahi = { services.avahi = {
enable = true; enable = true;
@ -16,11 +33,18 @@
# Firewall configuration # Firewall configuration
networking.firewall = { networking.firewall = {
# Samba allowedTCPPorts = [
allowedTCPPorts = [ 445 139 ]; 445 # Samba
allowedUDPPorts = [ 137 138 ]; 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
'';
}; };
# Disable IPv6
networking.enableIPv6 = false;
} }