Assign a static IP address

This commit is contained in:
coolneng 2022-01-05 13:54:59 +01:00
parent b9ed94d3ee
commit 278cec1682
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
2 changed files with 22 additions and 13 deletions

View File

@ -34,9 +34,6 @@
# Cleanup tmp on startup
boot.cleanTmpDir = true;
# Set hostname
networking.hostName = "zion";
# Create coolneng user
users.users.coolneng = {
isNormalUser = true;
@ -56,7 +53,6 @@
services.timesyncd.enable = true;
# Enable ZFS support
networking.hostId = "4e74ea68";
boot.supportedFilesystems = [ "zfs" ];
# Don't import encrypted datasets

View File

@ -1,6 +1,25 @@
{ config, pkgs, lib, ... }:
{
# Assign a static IP
networking = {
hostName = "zion";
hostId = "4e74ea68";
interfaces.eth0 = {
useDHCP = false;
ipv4.addresses = [{
address = "192.168.1.2";
prefixLength = 24;
}];
};
defaultGateway = {
address = "192.168.1.1";
interface = "eth0";
};
nameservers = [ "195.10.195.195" "165.22.224.164" ];
enableIPv6 = false;
};
# Enable zeroconf
services.avahi = {
enable = true;
@ -40,12 +59,6 @@
'';
};
# Disable IPv6
networking.enableIPv6 = false;
# Disable WiFi
networking.interfaces."eth0".useDHCP = true;
# Enable NAT for wireguard
networking.nat = {
enable = true;
@ -77,13 +90,13 @@
# DNS server with ad-block
services.dnsmasq = {
enable = true;
servers = [ "195.10.195.195" "165.22.224.164" ];
servers = config.networking.nameservers;
extraConfig = ''
domain-needed
bogus-priv
no-resolv
listen-address=127.0.0.1,192.168.13.2,10.8.0.1
listen-address=127.0.0.1,192.168.1.2,10.8.0.1
bind-interfaces
cache-size=10000
@ -91,7 +104,7 @@
conf-file=/var/lib/dnsmasq/dnsmasq.blacklist.txt
address=/coolneng.duckdns.org/192.168.13.2
address=/coolneng.duckdns.org/192.168.1.2
'';
};