blob: 5777626098c249848f7d296299dff8a45a473678 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
{ config, lib, pkgs, ... }: let
ipAddress = "10.1.1.1";
in {
# Setup bootloader
boot._loader.enable = true;
# Enable common options
_archetypes = {
profiles.headless = {
enable = true;
home.users.timmy.enable = true;
};
profiles.router.enable = true;
};
networking = {
# Label lan and wan interfaces
_interfaceLabels = {
enable = true;
interfaces = {
lan0 = "98:b7:85:22:9b:43"; # Internal
wan0 = "54:ee:75:8c:4b:2d"; # External
};
};
# Set ip addresses
interfaces = {
lan0.ipv4.addresses = [{
address = ipAddress;
prefixLength = 24;
}];
wan0.ipv4.addresses = [{
address = "46.110.173.163"; # Reserved static ip for wg-router
prefixLength = 31;
}];
};
defaultGateway = {
address = "46.110.173.161";
interface = "wan0";
};
nameservers = [ "127.0.0.1" ];
# Firewall rules
firewall = {
interfaces.wan0 = {
allowedTCPPorts = [ 22 ];
};
};
#nat.forwardPorts = [
# {
# sourcePort = 2222;
# proto = "tcp";
# destination = "10.1.1.1:22";
# }
# {
# sourcePort = 22;
# proto = "tcp";
# destination = "10.1.1.1:22";
# }
#];
};
services._router = {
dnsDhcpConfig = {
localDomain = "wg-router.pls.lan";
dhcp = {
defaultGateway = ipAddress;
localhostIp = ipAddress;
rangeStart = "10.1.1.100";
rangeEnd = "10.1.1.250";
staticLeases = {
idrac-8HT2W52 = {
macAddress = "18:fb:7b:9d:16:b3";
staticIp = "10.1.1.10";
};
};
};
};
};
# Enable user timmy
_users.timmy.enable = true;
system.stateVersion = "25.05";
}
|