1 { pkgs, lib, config, machines, ... }:
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.extraConfig = ''
34 interface: 192.168.2.1
35 access-control: 192.168.2.0/24 allow
36 local-zone: "tracking.intl.miui.com" always_refuse
37 local-zone: sourcephile.fr typetransparent
38 local-data: "bureau1.sourcephile.fr A 192.168.2.1"
41 networking.wlanInterfaces = {
48 networking.networkmanager.unmanaged = [
50 "interface-name:${iface}"
61 wpaPassphrase = "bidonpoissonmaisonronron";
68 interfaces = [ iface ];
70 option subnet-mask 255.255.255.0;
71 option broadcast-address 192.168.2.255;
72 option routers 192.168.2.1;
73 option domain-name-servers 192.168.2.1;
74 subnet 192.168.2.0 netmask 255.255.255.0 {
75 range 192.168.2.100 192.168.2.200;
80 #networking.firewall.allowedUDPPorts = [ 53 67 ]; # DNS & DHCP
82 # Sometimes slow connection speeds are attributed to absence of haveged.
83 services.haveged.enable = true;
88 systemd.services.wifi-relay = let inherit (pkgs) iptables gnugrep;
90 description = "iptables rules for wifi-relay";
91 after = [ "dhcpd4.service" ];
92 wantedBy = [ "multi-user.target" ];
94 ${iptables}/bin/iptables -w -t nat -I POSTROUTING -s 192.168.2.0/24 ! -o wlp4s0 -j MASQUERADE
95 ${iptables}/bin/iptables -w -I FORWARD -i wlp4s0 -s 192.168.2.0/24 -j ACCEPT
96 ${iptables}/bin/iptables -w -I FORWARD -i wlan-station0 -d 192.168.2.0/24 -j ACCEPT