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

View File

@ -1,6 +1,25 @@
{ config, pkgs, lib, ... }: { 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 # Enable zeroconf
services.avahi = { services.avahi = {
enable = true; enable = true;
@ -40,12 +59,6 @@
''; '';
}; };
# Disable IPv6
networking.enableIPv6 = false;
# Disable WiFi
networking.interfaces."eth0".useDHCP = true;
# Enable NAT for wireguard # Enable NAT for wireguard
networking.nat = { networking.nat = {
enable = true; enable = true;
@ -77,13 +90,13 @@
# DNS server with ad-block # DNS server with ad-block
services.dnsmasq = { services.dnsmasq = {
enable = true; enable = true;
servers = [ "195.10.195.195" "165.22.224.164" ]; servers = config.networking.nameservers;
extraConfig = '' extraConfig = ''
domain-needed domain-needed
bogus-priv bogus-priv
no-resolv 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 bind-interfaces
cache-size=10000 cache-size=10000
@ -91,7 +104,7 @@
conf-file=/var/lib/dnsmasq/dnsmasq.blacklist.txt conf-file=/var/lib/dnsmasq/dnsmasq.blacklist.txt
address=/coolneng.duckdns.org/192.168.13.2 address=/coolneng.duckdns.org/192.168.1.2
''; '';
}; };