nixfiles/hosts/raspberry/services/router.nix

50 lines
984 B
Nix
Raw Normal View History

2022-01-04 12:31:29 +00:00
{ lib, tree, ... }:
let
externalInterface = "eth0";
wifiInterface = "wlan0";
ssid = "Test Wifi";
password = "UwUPassUwU";
in {
2022-01-16 11:22:44 +00:00
imports = with tree; [ profiles.dnscrypt ];
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 ];
checkReversePath = false;
2022-01-16 11:22:44 +00:00
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" ];
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
}