1 { pkgs, lib, config, hosts, ... }:
5 networking.interfaces.${iface} = {
7 { address = "192.168.2.1"; prefixLength = 24; }
10 boot.kernel.sysctl."net.ipv6.conf.${iface}.addr_gen_mode" = 1;
11 networking.nftables.ruleset = ''
12 # Hook ${iface} into relevant chains
13 add rule inet filter input iifname "${iface}" jump wifi2fw
14 add rule inet filter input iifname "${iface}" log level warn prefix "wifi2fw: " counter drop
15 add rule inet filter output oifname "${iface}" jump fw2wifi
16 add rule inet filter output oifname "${iface}" log level warn prefix "fw2wifi: " counter drop
18 # ${iface} firewalling
19 add rule inet filter fw2wifi counter accept
20 add rule inet filter forward iifname "${iface}" jump fwd-wifi
22 # Allow forwarding to the internet
23 add rule inet filter fwd-wifi oifname "enp5s0" counter accept
25 # Allow networking services
26 add rule inet filter wifi2fw udp dport 53 counter accept comment "DNS"
27 add rule inet filter wifi2fw tcp dport 53 counter accept comment "DNS"
28 add rule inet filter wifi2fw tcp dport 67 counter accept comment "DHCP"
30 #boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
32 services.unbound.settings = {
34 interface = [ "192.168.2.1" ];
35 access-control = ["192.168.2.0/24 allow"];
37 "tracking.intl.miui.com always_refuse"
38 "sourcephile.fr typetransparent"
41 "\"bureau1.sourcephile.fr A 192.168.2.1\""
46 networking.wlanInterfaces = {
53 networking.networkmanager.unmanaged = [
55 "interface-name:${iface}"
66 wpaPassphrase = "bidonpoissonmaisonronron";
73 interfaces = [ iface ];
75 option subnet-mask 255.255.255.0;
76 option broadcast-address 192.168.2.255;
77 option routers 192.168.2.1;
78 option domain-name-servers 192.168.2.1;
79 subnet 192.168.2.0 netmask 255.255.255.0 {
80 range 192.168.2.100 192.168.2.200;
85 #networking.firewall.allowedUDPPorts = [ 53 67 ]; # DNS & DHCP
87 # Sometimes slow connection speeds are attributed to absence of haveged.
88 services.haveged.enable = true;
93 systemd.services.wifi-relay = let inherit (pkgs) iptables gnugrep;
95 description = "iptables rules for wifi-relay";
96 after = [ "dhcpd4.service" ];
97 wantedBy = [ "multi-user.target" ];
99 ${iptables}/bin/iptables -w -t nat -I POSTROUTING -s 192.168.2.0/24 ! -o wlp4s0 -j MASQUERADE
100 ${iptables}/bin/iptables -w -I FORWARD -i wlp4s0 -s 192.168.2.0/24 -j ACCEPT
101 ${iptables}/bin/iptables -w -I FORWARD -i wlan-station0 -d 192.168.2.0/24 -j ACCEPT