1 { config, pkgs, lib, hostName, ... }:
4 wwanIface = "wwp0s19u1u3i3"; # usb_modeswitch -W -v 12d1 -p 1573 -u 1
9 wifiIPv4 = "192.168.5";
10 eth1IPv4 = "192.168.2";
11 eth2IPv4 = "192.168.3";
12 eth3IPv4 = "192.168.4";
16 networking/nftables.nix
17 ../../nixos/profiles/networking.nix
18 ../../nixos/profiles/dnscrypt-proxy2.nix
19 ../../nixos/profiles/wireguard/wg-intra.nix
21 install.substituteOnDestination = false;
22 networking.domain = "sourcephile.fr";
23 networking.useDHCP = false;
25 boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
26 networking.nftables.ruleset = lib.mkAfter ''
29 iifname { ${wwanIface}, ${ftthIface} } jump input-net
30 iifname { ${wwanIface}, ${ftthIface} } log level warn prefix "input-net: " counter drop
32 iifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } jump input-lan
33 iifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } log level warn prefix "input-lan: " counter drop
36 oifname { ${wwanIface}, ${ftthIface} } jump output-net
37 oifname { ${wwanIface}, ${ftthIface} } log level warn prefix "output-net: " counter drop
39 oifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } jump output-lan
40 oifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } log level warn prefix "output-lan: " counter drop
42 chain forward-to-net {
43 #jump forward-connectivity
46 chain forward-from-net {
47 ct state { established, related } accept
48 log level warn prefix "forward-from-net: " counter drop
51 iifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } oifname { ${wwanIface}, ${ftthIface} } goto forward-to-net
52 iifname { ${wwanIface}, ${ftthIface} } oifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } goto forward-from-net
53 log level warn prefix "forward: " counter drop
58 iifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } oifname { ${wwanIface}, ${ftthIface} } masquerade
63 services.avahi.openFirewall = true;
64 services.dnscrypt-proxy2.settings.listen_addresses = [
72 networking.interfaces = {
78 ipv4.addresses = [ { address = "${wifiIPv4}.1"; prefixLength = 24; } ];
79 ipv4.routes = [ { address = "${wifiIPv4}.0"; prefixLength = 24; options = { congctl="westwood";}; } ];
83 ipv4.addresses = [ { address = "${eth1IPv4}.1"; prefixLength = 24; } ];
87 ipv4.addresses = [ { address = "${eth2IPv4}.1"; prefixLength = 24; } ];
91 ipv4.addresses = [ { address = "${eth3IPv4}.1"; prefixLength = 24; } ];
96 systemd.services.dhcpd4 = {
98 "network-addresses-${wifiIface}.service"
99 "network-addresses-${eth1Iface}.service"
100 "network-addresses-${eth2Iface}.service"
101 "network-addresses-${eth3Iface}.service"
113 subnet ${wifiIPv4}.0 netmask 255.255.255.0 {
114 range ${wifiIPv4}.100 ${wifiIPv4}.200;
115 option broadcast-address ${wifiIPv4}.255;
116 option domain-name-servers ${wifiIPv4}.1;
117 option routers ${wifiIPv4}.1;
118 option subnet-mask 255.255.255.0;
121 subnet ${eth1IPv4}.0 netmask 255.255.255.0 {
122 range ${eth1IPv4}.100 ${eth1IPv4}.200;
123 option broadcast-address ${eth1IPv4}.255;
124 option domain-name-servers ${eth1IPv4}.1;
125 option routers ${eth1IPv4}.1;
126 option subnet-mask 255.255.255.0;
129 subnet ${eth2IPv4}.0 netmask 255.255.255.0 {
130 range ${eth2IPv4}.100 ${eth2IPv4}.200;
131 option broadcast-address ${eth2IPv4}.255;
132 option domain-name-servers ${eth2IPv4}.1;
133 option routers ${eth2IPv4}.1;
134 option subnet-mask 255.255.255.0;
137 subnet ${eth3IPv4}.0 netmask 255.255.255.0 {
138 range ${eth3IPv4}.100 ${eth3IPv4}.200;
139 option broadcast-address ${eth3IPv4}.255;
140 option domain-name-servers ${eth3IPv4}.1;
141 option routers ${eth3IPv4}.1;
142 option subnet-mask 255.255.255.0;
147 systemd.services.NetworkManager.wants = [ "ModemManager.service" ];
148 networking.networkmanager = {
158 environment.etc."NetworkManager/system-connections/Prixtel.nmconnection" = {
163 uuid=b223f550-dff1-4ba3-9755-cd4557faaa5a
166 permissions=user:julm:;
179 addr-gen-mode=stable-privacy
186 networking.wireguard.wg-intra.peers = {
187 mermet.enable = true;
188 losurdo.enable = true;
189 oignon.enable = true;
190 patate.enable = true;
193 services.openssh.listenAddresses = [
194 { addr = "${wifiIPv4}.1"; port = 22; }
195 { addr = "${eth1IPv4}.1"; port = 22; }
196 { addr = "${eth2IPv4}.1"; port = 22; }
197 { addr = "${eth3IPv4}.1"; port = 22; }
200 environment.systemPackages = [
202 pkgs.modem-manager-gui
206 # https://gitlab.com/mobian1/callaudiod/-/issues/26
207 # https://gitlab.com/mobian1/callaudiod/-/issues/27
211 # iw dev wlp5s0 station dump
212 # DOC: https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf
216 interface = wifiIface;
217 # 0 means the AP will search for the channel with the least interferences (ACS)
222 #wpaPassphrase = "bidonpoissonmaisonronron";
227 dtim_period=2 # DTIM (delivery trafic information message)
229 # limit the frequencies used to those allowed in the country
233 #wpa_key_mgmt=WPA-PSK
236 #auth_algs=1 # 0=noauth, 1=wpa, 2=wep, 3=both
238 # QoS support, also required for full speed on 802.11n/ac/ax
240 eap_reauth_period=360000
247 # See Capabilities in iw list
248 #ht_capab=[HT40+][SHORT-GI-40][DSSS_CCK-40][MAX-AMSDU-3839]