2019-12-02 14:58:40 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
with import <stockholm/lib>;
|
|
|
|
|
|
|
|
{
|
2023-01-18 19:07:32 +00:00
|
|
|
# ipv6 from vodafone is really really flaky
|
|
|
|
boot.kernel.sysctl."net.ipv6.conf.et0.disable_ipv6" = 1;
|
2023-01-08 19:39:39 +00:00
|
|
|
systemd.network.networks."50-et0" = {
|
|
|
|
matchConfig.Name = "et0";
|
2023-01-18 19:07:32 +00:00
|
|
|
DHCP = "ipv4";
|
2023-01-08 19:39:39 +00:00
|
|
|
# dhcpV4Config.UseDNS = false;
|
|
|
|
# dhcpV6Config.UseDNS = false;
|
|
|
|
linkConfig = {
|
|
|
|
RequiredForOnline = "routable";
|
|
|
|
};
|
|
|
|
# networkConfig = {
|
|
|
|
# LinkLocalAddressing = "no";
|
|
|
|
# };
|
|
|
|
# dhcpV6Config = {
|
|
|
|
# PrefixDelegationHint = "::/60";
|
|
|
|
# };
|
|
|
|
# networkConfig = {
|
|
|
|
# IPv6AcceptRA = true;
|
|
|
|
# };
|
|
|
|
# ipv6PrefixDelegationConfig = {
|
|
|
|
# Managed = true;
|
|
|
|
# };
|
|
|
|
};
|
2023-01-18 19:08:13 +00:00
|
|
|
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
|
2023-01-08 19:39:39 +00:00
|
|
|
systemd.network.networks."50-int0" = {
|
|
|
|
name = "int0";
|
|
|
|
address = [
|
|
|
|
"10.42.0.1/24"
|
|
|
|
];
|
|
|
|
networkConfig = {
|
2023-01-18 19:08:13 +00:00
|
|
|
# IPForward = "yes";
|
|
|
|
# IPMasquerade = "both";
|
2023-01-08 19:39:39 +00:00
|
|
|
ConfigureWithoutCarrier = true;
|
|
|
|
DHCPServer = "yes";
|
|
|
|
# IPv6SendRA = "yes";
|
|
|
|
# DHCPPrefixDelegation = "yes";
|
|
|
|
};
|
|
|
|
};
|
2019-12-02 14:58:40 +00:00
|
|
|
networking.networkmanager.unmanaged = [ "int0" ];
|
2023-01-08 19:39:39 +00:00
|
|
|
krebs.iptables.tables.filter.INPUT.rules = [
|
|
|
|
{ predicate = "-i int0"; target = "ACCEPT"; }
|
|
|
|
];
|
|
|
|
krebs.iptables.tables.filter.FORWARD.rules = [
|
|
|
|
{ predicate = "-i int0"; target = "ACCEPT"; }
|
|
|
|
{ predicate = "-o int0"; target = "ACCEPT"; }
|
|
|
|
{ predicate = "-p ipv6-icmp"; target = "ACCEPT"; v4 = false; }
|
|
|
|
];
|
|
|
|
krebs.iptables.tables.nat.PREROUTING.rules = mkBefore [
|
|
|
|
{ v6 = false; predicate = "-s 10.42.0.0/24"; target = "ACCEPT"; }
|
|
|
|
];
|
2023-01-18 19:08:13 +00:00
|
|
|
krebs.iptables.tables.nat.POSTROUTING.rules = [
|
|
|
|
{ v6 = false; predicate = "-s 10.42.0.0/24"; target = "MASQUERADE"; }
|
|
|
|
];
|
2019-12-02 14:58:40 +00:00
|
|
|
|
2021-06-05 10:57:33 +00:00
|
|
|
networking.domain = "gg23";
|
|
|
|
|
2023-01-18 19:08:49 +00:00
|
|
|
networking.useHostResolvConf = false;
|
|
|
|
services.resolved.extraConfig = ''
|
|
|
|
DNSStubListener=no
|
|
|
|
'';
|
2019-12-02 14:58:40 +00:00
|
|
|
services.dnsmasq = {
|
|
|
|
enable = true;
|
|
|
|
resolveLocalQueries = false;
|
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
local=/gg23/
|
|
|
|
domain=gg23
|
|
|
|
expand-hosts
|
|
|
|
listen-address=10.42.0.1
|
|
|
|
interface=int0
|
|
|
|
'';
|
|
|
|
};
|
2023-01-18 19:09:02 +00:00
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
(pkgs.writers.writeDashBin "restart_router" ''
|
|
|
|
${pkgs.mosquitto}/bin/mosquitto_pub -h localhost -t 'cmnd/router/POWER' -u gg23 -P gg23-mqtt -m OFF
|
|
|
|
sleep 2
|
|
|
|
${pkgs.mosquitto}/bin/mosquitto_pub -h localhost -t 'cmnd/router/POWER' -u gg23 -P gg23-mqtt -m ON
|
|
|
|
'')
|
|
|
|
];
|
2019-12-02 14:58:40 +00:00
|
|
|
}
|