nixfiles/hosts/raspberry/services/router.nix

52 lines
974 B
Nix
Raw Normal View History

{
lib,
tree,
...
}: let
2022-01-04 12:31:29 +00:00
externalInterface = "eth0";
wifiInterface = "wlan0";
ssid = "Test Wifi";
password = "UwUPassUwU";
in {
imports = with tree; [profiles.dnscrypt];
2022-01-16 11:22:44 +00:00
services.dnscrypt-proxy2.settings."listen_addresses" = ["0.0.0.0:53" "[::]:53"];
2022-01-04 12:31:29 +00:00
services.hostapd = {
enable = true;
interface = wifiInterface;
2022-02-10 10:37:09 +00:00
inherit ssid;
2022-01-04 12:31:29 +00:00
wpaPassphrase = password;
};
networking.interfaces = {
wlan0 = {
ipAddress = "192.168.2.1";
prefixLength = 24;
};
};
networking.firewall = {
trustedInterfaces = [wifiInterface];
2022-01-04 12:31:29 +00:00
checkReversePath = false;
allowedTCPPorts = [53];
2022-01-04 12:31:29 +00:00
};
networking.nat = {
enable = true;
internalIPs = ["192.168.2.0/24"];
2022-02-10 10:37:09 +00:00
inherit externalInterface;
2022-01-04 12:31:29 +00:00
};
services.dnsmasq = {
enable = true;
servers = ["192.168.2.1"];
2022-01-04 12:31:29 +00:00
extraConfig = ''
domain=lan
interface=wlan0
bind-interfaces
dhcp-range=192.168.2.10,192.168.2.254,24h
'';
};
2022-01-16 11:22:44 +00:00
}