2024-12-07 14:01:25 +08:00
|
|
|
{
|
|
|
|
profiles,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}:
|
2024-11-28 01:14:34 +08:00
|
|
|
{
|
|
|
|
imports = with profiles; [
|
2024-12-13 17:27:36 +08:00
|
|
|
services.enthalpy.customer-dualstack
|
2024-11-28 01:14:34 +08:00
|
|
|
];
|
|
|
|
|
2024-12-22 22:20:43 +08:00
|
|
|
systemd.services.nix-daemon = {
|
|
|
|
inherit (config.networking.netns.enthalpy) serviceConfig;
|
|
|
|
after = [ "netns-enthalpy.service" ];
|
|
|
|
requires = [ "netns-enthalpy.service" ];
|
|
|
|
};
|
|
|
|
|
2024-12-13 17:27:36 +08:00
|
|
|
services.enthalpy = {
|
|
|
|
ipsec.interfaces = [ "enp2s0" ];
|
|
|
|
clat.segment = lib.singleton "fde3:3be3:a244:f876::2";
|
|
|
|
};
|
2024-11-28 01:14:34 +08:00
|
|
|
|
|
|
|
systemd.network = {
|
|
|
|
enable = true;
|
|
|
|
wait-online.anyInterface = true;
|
|
|
|
config = {
|
|
|
|
networkConfig = {
|
|
|
|
IPv4Forwarding = true;
|
|
|
|
IPv6Forwarding = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
networks = {
|
|
|
|
"30-enp1s0" = {
|
|
|
|
matchConfig.Name = "enp1s0";
|
|
|
|
networkConfig = {
|
|
|
|
DHCPServer = "yes";
|
|
|
|
IPv6SendRA = "yes";
|
|
|
|
IPv6PrivacyExtensions = true;
|
|
|
|
IPv6AcceptRA = "no";
|
|
|
|
KeepConfiguration = true;
|
|
|
|
};
|
|
|
|
dhcpServerConfig = {
|
|
|
|
ServerAddress = "100.64.0.1/20";
|
|
|
|
EmitDNS = true;
|
2024-12-02 22:16:31 +08:00
|
|
|
DNS = "10.10.0.21";
|
2024-11-28 01:14:34 +08:00
|
|
|
};
|
|
|
|
ipv6Prefixes = lib.singleton {
|
|
|
|
Prefix = "fdce:2962:c3c1:130c::/64";
|
|
|
|
Assign = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
"30-enp2s0" = {
|
|
|
|
matchConfig.Name = "enp2s0";
|
|
|
|
networkConfig = {
|
|
|
|
DHCP = "yes";
|
|
|
|
IPv6AcceptRA = true;
|
|
|
|
IPv6PrivacyExtensions = true;
|
|
|
|
KeepConfiguration = true;
|
|
|
|
};
|
|
|
|
dhcpV4Config.RouteMetric = 1024;
|
|
|
|
dhcpV6Config.RouteMetric = 1024;
|
|
|
|
ipv6AcceptRAConfig.RouteMetric = 1024;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.nftables.tables.nat = {
|
|
|
|
family = "inet";
|
|
|
|
content = ''
|
|
|
|
chain input {
|
|
|
|
type filter hook input priority mangle; policy accept;
|
|
|
|
iifname enp2s0 tcp dport { http, https } counter drop
|
|
|
|
iifname enp2s0 udp dport { http, https } counter drop
|
|
|
|
}
|
|
|
|
|
|
|
|
chain postrouting {
|
|
|
|
type nat hook postrouting priority srcnat; policy accept;
|
|
|
|
oifname enp2s0 counter masquerade
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|