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; } ];
82 ipv4.addresses = [ { address = "${eth1IPv4}.1"; prefixLength = 24; } ];
86 ipv4.addresses = [ { address = "${eth2IPv4}.1"; prefixLength = 24; } ];
90 ipv4.addresses = [ { address = "${eth3IPv4}.1"; prefixLength = 24; } ];
95 systemd.services.dhcpd4 = {
97 "network-addresses-${wifiIface}.service"
98 "network-addresses-${eth1Iface}.service"
99 "network-addresses-${eth2Iface}.service"
100 "network-addresses-${eth3Iface}.service"
112 option subnet-mask 255.255.255.0;
114 option broadcast-address ${wifiIPv4}.255;
115 option routers ${wifiIPv4}.1;
116 option domain-name-servers ${wifiIPv4}.1;
117 subnet ${wifiIPv4}.0 netmask 255.255.255.0 {
118 range ${wifiIPv4}.100 ${wifiIPv4}.200;
121 option broadcast-address ${eth1IPv4}.255;
122 option routers ${eth1IPv4}.1;
123 option domain-name-servers ${eth1IPv4}.1;
124 subnet ${eth1IPv4}.0 netmask 255.255.255.0 {
125 range ${eth1IPv4}.100 ${eth1IPv4}.200;
128 option broadcast-address ${eth2IPv4}.255;
129 option routers ${eth2IPv4}.1;
130 option domain-name-servers ${eth2IPv4}.1;
131 subnet ${eth2IPv4}.0 netmask 255.255.255.0 {
132 range ${eth2IPv4}.100 ${eth2IPv4}.200;
135 option broadcast-address ${eth3IPv4}.255;
136 option routers ${eth3IPv4}.1;
137 option domain-name-servers ${eth3IPv4}.1;
138 subnet ${eth3IPv4}.0 netmask 255.255.255.0 {
139 range ${eth3IPv4}.100 ${eth3IPv4}.200;
144 systemd.services.NetworkManager.wants = [ "ModemManager.service" ];
145 networking.networkmanager = {
155 environment.etc."NetworkManager/system-connections/Prixtel.nmconnection" = {
160 uuid=b223f550-dff1-4ba3-9755-cd4557faaa5a
163 permissions=user:julm:;
176 addr-gen-mode=stable-privacy
183 networking.wireguard.wg-intra.peers = {
184 mermet.enable = true;
185 losurdo.enable = true;
186 oignon.enable = true;
187 patate.enable = true;
190 services.openssh.listenAddresses = [
191 { addr = "${wifiIPv4}.1"; port = 22; }
192 { addr = "${eth1IPv4}.1"; port = 22; }
193 { addr = "${eth2IPv4}.1"; port = 22; }
194 { addr = "${eth3IPv4}.1"; port = 22; }
197 environment.systemPackages = [
199 pkgs.modem-manager-gui
202 # iw dev wlp5s0 station dump
203 # DOC: https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf
207 interface = wifiIface;
208 # 0 means the AP will search for the channel with the least interferences (ACS)
213 #wpaPassphrase = "bidonpoissonmaisonronron";
218 dtim_period=2 # DTIM (delivery trafic information message)
220 # limit the frequencies used to those allowed in the country
224 #wpa_key_mgmt=WPA-PSK
227 #auth_algs=1 # 0=noauth, 1=wpa, 2=wep, 3=both
229 # QoS support, also required for full speed on 802.11n/ac/ax
231 eap_reauth_period=360000
238 # See Capabilities in iw list
239 #ht_capab=[HT40+][SHORT-GI-40][DSSS_CCK-40][MAX-AMSDU-3839]