2024-03-06 19:14:58 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
modulesPath,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
# inherit (pkgs.liminix.services)
|
|
|
|
# oneshot
|
|
|
|
# longrun
|
|
|
|
# bundle
|
|
|
|
# target
|
|
|
|
# ;
|
|
|
|
# inherit (pkgs) writeText;
|
|
|
|
svc = config.system.service;
|
|
|
|
secrets-1 = {
|
2024-08-22 18:45:40 +02:00
|
|
|
ssid = "DGNum 2G prototype (N)";
|
2024-03-06 19:14:58 +01:00
|
|
|
};
|
|
|
|
secrets-2 = {
|
2024-08-22 18:45:40 +02:00
|
|
|
ssid = "DGNum 5G prototype (AX)";
|
2024-03-06 19:14:58 +01:00
|
|
|
};
|
|
|
|
baseParams = {
|
|
|
|
country_code = "FR";
|
|
|
|
hw_mode = "g";
|
|
|
|
channel = 6;
|
|
|
|
wmm_enabled = 1;
|
|
|
|
ieee80211n = 1;
|
|
|
|
ht_capab = "[LDPC][GF][HT40-][HT40+][SHORT-GI-40][MAX-AMSDU-7935][TX-STBC]";
|
|
|
|
auth_algs = 1;
|
|
|
|
wpa = 2;
|
|
|
|
wpa_pairwise = "TKIP CCMP";
|
|
|
|
rsn_pairwise = "CCMP";
|
|
|
|
};
|
|
|
|
|
2024-08-31 22:21:35 +02:00
|
|
|
radiusKeyMgmt = {
|
|
|
|
wpa_key_mgmt = "WPA-EAP";
|
|
|
|
};
|
|
|
|
|
2024-03-06 19:14:58 +01:00
|
|
|
modernParams = {
|
|
|
|
hw_mode = "a";
|
|
|
|
he_su_beamformer = 1;
|
|
|
|
he_su_beamformee = 1;
|
|
|
|
he_mu_beamformer = 1;
|
|
|
|
preamble = 1;
|
|
|
|
# Allow radar detection.
|
|
|
|
ieee80211d = 1;
|
|
|
|
ieee80211h = 1;
|
|
|
|
ieee80211ac = 1;
|
|
|
|
ieee80211ax = 1;
|
|
|
|
vht_capab = "[MAX-MPDU-7991][SU-BEAMFORMEE][SU-BEAMFORMER][RXLDPC][SHORT-GI-80][MAX-A-MPDU-LEN-EXP3][RX-ANTENNA-PATTERN][TX-ANTENNA-PATTERN][TX-STBC-2BY1][RX-STBC-1][MU-BEAMFORMER]";
|
|
|
|
vht_oper_chwidth = 1;
|
|
|
|
he_oper_chwidth = 1;
|
|
|
|
channel = 36;
|
|
|
|
vht_oper_centr_freq_seg0_idx = 42;
|
|
|
|
he_oper_centr_freq_seg0_idx = 42;
|
|
|
|
require_vht = 1;
|
|
|
|
};
|
2024-08-31 22:21:35 +02:00
|
|
|
|
|
|
|
clientRadius = {
|
|
|
|
ieee8021x = 1;
|
|
|
|
eapol_version = 2;
|
|
|
|
use_pae_group_addr = 1;
|
|
|
|
dynamic_vlan = 0;
|
|
|
|
vlan_tagged_interface = "lan";
|
|
|
|
};
|
|
|
|
|
|
|
|
serverRadius = {
|
|
|
|
radius_server_clients = pkgs.writeText "clients" ''
|
|
|
|
0.0.0.0/0 dgnum
|
|
|
|
'';
|
|
|
|
radius_server_auth_port = 1812;
|
|
|
|
radius_server_ipv6 = 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
localRadius = {
|
|
|
|
eap_server = 1;
|
|
|
|
eap_user_file = pkgs.writeText "user.db" ''
|
|
|
|
# anonymous login in phase 1
|
|
|
|
* PEAP
|
|
|
|
# password based in the secure tunnel in phase 2
|
|
|
|
"test" MSCHAPV2 "diamond dogs" [2]
|
|
|
|
'';
|
|
|
|
|
|
|
|
# DGNum CA certificate.
|
|
|
|
ca_cert = builtins.toFile "dgnum-test-ap-ca" (
|
|
|
|
builtins.readFile ../../keys/certs/dgnum-test-ap-ca.crt
|
|
|
|
);
|
|
|
|
# Server certificate for this AP.
|
|
|
|
server_cert = builtins.toFile "dgnum-ap-server" (
|
|
|
|
builtins.readFile ../../keys/certs/dgnum-ap-server.crt
|
|
|
|
);
|
|
|
|
private_key = builtins.toFile "dgnum-ap-server-pkey" (
|
|
|
|
builtins.readFile ../../keys/certs/dgnum-ap-server.key.pem
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
# externalRadius = {
|
|
|
|
# own_ip_addr = "";
|
|
|
|
# nas_identifier = "";
|
|
|
|
|
|
|
|
# auth_server_addr = "";
|
|
|
|
# auth_server_port = 1812;
|
|
|
|
# auth_server_shared_secret = "dgnum";
|
|
|
|
# };
|
|
|
|
|
2024-03-06 19:14:58 +01:00
|
|
|
mkWifiSta =
|
|
|
|
params: interface: secrets:
|
|
|
|
svc.hostapd.build {
|
|
|
|
inherit interface;
|
2024-08-31 22:21:35 +02:00
|
|
|
package = pkgs.hostapd-radius;
|
|
|
|
params = params // secrets;
|
2024-03-06 19:14:58 +01:00
|
|
|
};
|
|
|
|
in
|
|
|
|
rec {
|
|
|
|
imports = [
|
|
|
|
"${modulesPath}/wlan.nix"
|
|
|
|
"${modulesPath}/network"
|
|
|
|
"${modulesPath}/hostapd"
|
|
|
|
"${modulesPath}/ssh"
|
|
|
|
"${modulesPath}/ntp"
|
|
|
|
"${modulesPath}/vlan"
|
|
|
|
"${modulesPath}/bridge"
|
2024-08-31 22:21:35 +02:00
|
|
|
"${modulesPath}/jitter-rng"
|
|
|
|
"${modulesPath}/pki"
|
2024-08-22 18:45:40 +02:00
|
|
|
../../modules/dgn-access-control.nix
|
|
|
|
# TODO: god that's so a fucking hack.
|
|
|
|
(import "${modulesPath}/../devices/zyxel-nwa50ax").module
|
2024-03-06 19:14:58 +01:00
|
|
|
];
|
|
|
|
|
2024-08-22 18:45:40 +02:00
|
|
|
hostname = "ap01-prototype";
|
2024-03-06 19:14:58 +01:00
|
|
|
|
2024-08-31 22:21:35 +02:00
|
|
|
security.pki = {
|
|
|
|
installCACerts = true;
|
|
|
|
certificateFiles = [
|
|
|
|
../../keys/certs/dgnum-test-ap-ca.crt
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-08-22 18:45:40 +02:00
|
|
|
# SSH keys are handled by the access control module.
|
|
|
|
dgn-access-control.enable = true;
|
2024-03-06 19:14:58 +01:00
|
|
|
users.root = {
|
|
|
|
# EDIT: choose a root password and then use
|
|
|
|
# "mkpasswd -m sha512crypt" to determine the hash.
|
|
|
|
# It should start wirh $6$.
|
2024-08-22 18:45:40 +02:00
|
|
|
passwd = "$6$jVXFFOp8HBYmgINR$lutB4kvw.W1jlXRby9ZYAgBitQ32RxQdYAGN.s2x4ris8J07vM6tzlRBQoeLELOIEMClDzbciQV0itfHQnTqd1";
|
2024-03-06 19:14:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services.int = svc.bridge.primary.build { ifname = "int"; };
|
|
|
|
|
|
|
|
services.bridge = svc.bridge.members.build {
|
|
|
|
primary = services.int;
|
|
|
|
members = with config.hardware.networkInterfaces; [
|
|
|
|
lan
|
|
|
|
wlan0
|
|
|
|
wlan1
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.dhcpv4 =
|
|
|
|
let
|
|
|
|
iface = services.int;
|
|
|
|
in
|
|
|
|
svc.network.dhcp.client.build { interface = iface; };
|
|
|
|
|
|
|
|
services.defaultroute4 = svc.network.route.build {
|
|
|
|
via = "$(output ${services.dhcpv4} address)";
|
|
|
|
target = "default";
|
|
|
|
dependencies = [ services.dhcpv4 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.packet_forwarding = svc.network.forward.build { };
|
|
|
|
services.sshd = svc.ssh.build { allowRoot = true; };
|
|
|
|
|
|
|
|
services.ntp = config.system.service.ntp.build {
|
|
|
|
pools = {
|
|
|
|
"pool.ntp.org" = [ "iburst" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
boot.tftp = {
|
|
|
|
serverip = "192.0.2.10";
|
|
|
|
ipaddr = "192.0.2.12";
|
|
|
|
};
|
|
|
|
|
|
|
|
# wlan0 is the 2.4GHz interface.
|
2024-08-31 22:21:35 +02:00
|
|
|
services.hostap-1 = mkWifiSta (
|
|
|
|
baseParams // clientRadius // localRadius // serverRadius // radiusKeyMgmt
|
|
|
|
) config.hardware.networkInterfaces.wlan0 secrets-1;
|
2024-03-06 19:14:58 +01:00
|
|
|
# wlan1 is the 5GHz interface, e.g. AX capable.
|
2024-05-13 17:04:49 +02:00
|
|
|
services.hostap-2 = mkWifiSta (
|
2024-08-31 22:21:35 +02:00
|
|
|
baseParams // clientRadius // localRadius // serverRadius // radiusKeyMgmt // modernParams
|
2024-05-13 17:04:49 +02:00
|
|
|
) config.hardware.networkInterfaces.wlan1 secrets-2;
|
2024-03-06 19:14:58 +01:00
|
|
|
|
|
|
|
defaultProfile.packages = with pkgs; [
|
|
|
|
zyxel-bootconfig
|
|
|
|
iw
|
|
|
|
min-collect-garbage
|
|
|
|
mtdutils
|
|
|
|
];
|
|
|
|
}
|