2018-03-31 22:16:38 +02:00
|
|
|
|
# Edit this configuration file to define what should be installed on
|
|
|
|
|
# your system. Help is available in the configuration.nix(5) man page
|
|
|
|
|
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
|
|
|
|
|
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
{
|
2018-09-04 14:05:06 +02:00
|
|
|
|
imports = [
|
2019-10-04 22:01:49 +02:00
|
|
|
|
../common-cli.nix
|
2018-09-04 14:05:06 +02:00
|
|
|
|
./hardware-configuration.nix
|
|
|
|
|
./users.nix
|
|
|
|
|
./services.nix
|
|
|
|
|
];
|
2018-03-31 22:16:38 +02:00
|
|
|
|
|
2022-12-30 15:08:20 +01:00
|
|
|
|
nix.settings.trusted-users = [ "root" "paul" ];
|
2021-12-16 19:07:52 +01:00
|
|
|
|
|
2018-09-04 14:05:06 +02:00
|
|
|
|
boot = {
|
|
|
|
|
loader = {
|
|
|
|
|
systemd-boot.enable = true;
|
|
|
|
|
efi.canTouchEfiVariables = true;
|
|
|
|
|
};
|
2018-03-31 22:16:38 +02:00
|
|
|
|
|
2018-09-04 14:05:06 +02:00
|
|
|
|
supportedFilesystems = [ "zfs" ];
|
2018-03-31 22:16:38 +02:00
|
|
|
|
|
2023-06-13 14:05:05 +02:00
|
|
|
|
tmp.useTmpfs = true;
|
2023-09-15 15:27:47 +02:00
|
|
|
|
|
|
|
|
|
kernel.sysctl."net.ipv6.conf.all.forwarding" = true;
|
2018-09-04 14:05:06 +02:00
|
|
|
|
};
|
2018-04-05 19:22:09 +02:00
|
|
|
|
|
2021-01-06 02:06:34 +01:00
|
|
|
|
documentation.nixos.enable = false;
|
|
|
|
|
|
2018-09-04 14:05:06 +02:00
|
|
|
|
services.zfs = {
|
|
|
|
|
autoSnapshot.enable = true;
|
2022-06-30 18:58:34 +02:00
|
|
|
|
autoScrub = {
|
|
|
|
|
enable = true;
|
|
|
|
|
interval = "monthly";
|
|
|
|
|
};
|
2018-09-04 14:05:06 +02:00
|
|
|
|
};
|
2018-03-31 22:16:38 +02:00
|
|
|
|
|
2020-08-30 16:25:51 +02:00
|
|
|
|
hardware.usbWwan.enable = true;
|
|
|
|
|
|
2019-04-04 23:47:24 +02:00
|
|
|
|
# eno1 -> VLAN100 -> Internet
|
|
|
|
|
# eno2 -> LAN
|
2019-04-21 11:05:45 +02:00
|
|
|
|
# eno3 -> Legacy client DHCP
|
|
|
|
|
# eno4 -> Pas utilisé
|
2019-04-04 23:47:24 +02:00
|
|
|
|
|
2018-09-04 14:05:06 +02:00
|
|
|
|
networking = {
|
|
|
|
|
hostName = "loutreos"; # Define your hostname.
|
|
|
|
|
hostId = "7e66e347";
|
2019-04-04 23:47:24 +02:00
|
|
|
|
|
2024-02-22 13:32:38 +01:00
|
|
|
|
hosts = {
|
|
|
|
|
"127.0.0.1" = [ "gitea.nyanlout.re" ];
|
|
|
|
|
};
|
|
|
|
|
|
2021-12-16 20:17:40 +01:00
|
|
|
|
useNetworkd = true;
|
|
|
|
|
useDHCP = false;
|
2019-04-27 10:36:01 +02:00
|
|
|
|
|
2020-08-30 21:10:48 +02:00
|
|
|
|
vlans = {
|
2021-12-20 08:33:43 +01:00
|
|
|
|
bouygues = {
|
2020-08-30 21:10:48 +02:00
|
|
|
|
id = 100;
|
|
|
|
|
interface = "eno1";
|
|
|
|
|
};
|
2019-04-04 23:47:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
interfaces = {
|
2021-12-20 08:33:43 +01:00
|
|
|
|
bouygues = {
|
2019-04-04 23:47:24 +02:00
|
|
|
|
# Adresse MAC BBox ? https://lafibre.info/remplacer-bbox/informations-de-connexion-ftth/msg598303/#msg598303
|
2019-04-27 10:36:01 +02:00
|
|
|
|
macAddress = "E8:AD:A6:21:73:68";
|
2021-12-16 20:17:40 +01:00
|
|
|
|
useDHCP = true;
|
2019-04-04 23:47:24 +02:00
|
|
|
|
};
|
|
|
|
|
eno2 = {
|
|
|
|
|
ipv4.addresses = [
|
|
|
|
|
{ address = "10.30.0.1"; prefixLength = 16; }
|
|
|
|
|
];
|
|
|
|
|
};
|
2023-09-21 23:52:56 +02:00
|
|
|
|
enp0s21u1.useDHCP = true;
|
2019-04-04 23:47:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
2021-12-20 08:33:43 +01:00
|
|
|
|
# NAT bouygues <-> eno2
|
2019-04-04 23:47:24 +02:00
|
|
|
|
nat = {
|
|
|
|
|
enable = true;
|
2021-12-20 08:33:43 +01:00
|
|
|
|
externalInterface = "bouygues";
|
2019-04-04 23:47:24 +02:00
|
|
|
|
# Permet d'utiliser le SNAT plus rapide au lieu de MASQUERADE
|
|
|
|
|
# externalIP = "0.0.0.0";
|
2023-06-13 14:47:44 +02:00
|
|
|
|
internalIPs = [ "10.30.0.0/16" ];
|
|
|
|
|
internalInterfaces = [ "eno2" ];
|
2019-06-07 10:28:24 +02:00
|
|
|
|
forwardPorts = [
|
|
|
|
|
{ destination = "10.30.0.1:22"; proto = "tcp"; sourcePort = 8443;}
|
2019-10-22 00:34:08 +02:00
|
|
|
|
{ destination = "10.30.135.35:25565"; proto = "tcp"; sourcePort = 25565; loopbackIPs=[ "195.36.180.44" ];}
|
2019-06-07 10:28:24 +02:00
|
|
|
|
];
|
2019-04-04 23:47:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
2019-04-27 11:34:17 +02:00
|
|
|
|
firewall = {
|
2023-09-15 15:27:47 +02:00
|
|
|
|
enable = true;
|
2020-04-08 12:45:36 +02:00
|
|
|
|
allowedTCPPorts = [ 80 443 ];
|
2019-04-27 11:34:17 +02:00
|
|
|
|
allowedUDPPorts = [ ];
|
|
|
|
|
interfaces.eno2 = {
|
|
|
|
|
allowedTCPPorts = [
|
|
|
|
|
111 2049 4000 4001 4002 # NFS
|
|
|
|
|
3483 9000 9090 # Slimserver
|
2020-04-08 12:48:42 +02:00
|
|
|
|
1935 # RTMP
|
2019-04-27 11:34:17 +02:00
|
|
|
|
];
|
|
|
|
|
allowedUDPPorts = [
|
|
|
|
|
111 2049 4000 4001 4002 # NFS
|
|
|
|
|
3483 # Slimserver
|
2023-09-21 23:29:14 +02:00
|
|
|
|
67 # DHCP
|
2019-04-27 11:34:17 +02:00
|
|
|
|
];
|
|
|
|
|
};
|
2023-09-15 15:27:47 +02:00
|
|
|
|
extraCommands = ''
|
2024-05-14 22:24:36 +02:00
|
|
|
|
ip6tables -w -D FORWARD -j loutreos-forward 2>/dev/null || true
|
|
|
|
|
ip6tables -w -F loutreos-forward 2>/dev/null || true
|
|
|
|
|
ip6tables -w -X loutreos-forward 2>/dev/null || true
|
|
|
|
|
ip6tables -w -N loutreos-forward
|
|
|
|
|
ip6tables -A loutreos-forward -m state --state RELATED,ESTABLISHED -j ACCEPT
|
|
|
|
|
ip6tables -A loutreos-forward -j ACCEPT -i eno2
|
|
|
|
|
ip6tables -A loutreos-forward -j nixos-fw-log-refuse
|
|
|
|
|
ip6tables -w -A FORWARD -j loutreos-forward
|
|
|
|
|
|
2024-02-22 11:10:45 +01:00
|
|
|
|
# Redirect local network request from server external IP to internal IP
|
|
|
|
|
# Make the server available even without internet access
|
2024-02-22 13:33:11 +01:00
|
|
|
|
iptables -t nat -D PREROUTING -s 10.30.0.0/16 -d 176.180.172.105 -j DNAT --to 10.30.0.1 || true
|
2024-02-22 11:10:45 +01:00
|
|
|
|
iptables -t nat -A PREROUTING -s 10.30.0.0/16 -d 176.180.172.105 -j DNAT --to 10.30.0.1
|
2023-09-15 15:27:47 +02:00
|
|
|
|
'';
|
2024-05-14 22:43:29 +02:00
|
|
|
|
extraStopCommands = ''
|
|
|
|
|
|
|
|
|
|
'';
|
2019-04-27 11:34:17 +02:00
|
|
|
|
};
|
2019-04-04 23:47:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
2021-12-20 08:34:21 +01:00
|
|
|
|
systemd.network.networks = {
|
2021-12-22 22:54:44 +01:00
|
|
|
|
"40-bouygues" = {
|
|
|
|
|
dhcpV4Config.RouteMetric = 1;
|
2022-10-14 14:54:22 +02:00
|
|
|
|
dhcpV6Config = {
|
|
|
|
|
DUIDRawData = "00:03:00:01:E8:AD:A6:21:73:68";
|
|
|
|
|
WithoutRA = "solicit";
|
|
|
|
|
};
|
2023-09-15 15:57:00 +02:00
|
|
|
|
ipv6AcceptRAConfig.DHCPv6Client = true;
|
2022-10-14 14:54:22 +02:00
|
|
|
|
networkConfig = {
|
|
|
|
|
KeepConfiguration = "dhcp-on-stop";
|
2023-09-15 15:57:00 +02:00
|
|
|
|
IPv6AcceptRA = true;
|
2023-10-10 22:17:02 +02:00
|
|
|
|
DHCPPrefixDelegation = true;
|
2022-10-14 14:54:22 +02:00
|
|
|
|
};
|
2024-01-27 17:43:21 +01:00
|
|
|
|
dhcpPrefixDelegationConfig.SubnetId = "0";
|
2021-12-22 22:54:44 +01:00
|
|
|
|
};
|
2024-05-14 22:26:42 +02:00
|
|
|
|
"40-eno1".linkConfig.RequiredForOnline = "no";
|
2023-09-15 15:27:47 +02:00
|
|
|
|
"40-eno2" = {
|
|
|
|
|
networkConfig = {
|
2023-09-15 15:57:00 +02:00
|
|
|
|
IPv6SendRA = true;
|
|
|
|
|
DHCPPrefixDelegation = true;
|
2023-09-21 23:29:14 +02:00
|
|
|
|
DHCPServer = true;
|
2023-09-15 15:57:00 +02:00
|
|
|
|
};
|
2023-09-21 23:29:14 +02:00
|
|
|
|
dhcpServerConfig = {
|
|
|
|
|
# MIN = 10.30.100.0
|
|
|
|
|
#PoolOffset = 25500;
|
|
|
|
|
# MAX = 10.30.200.0
|
|
|
|
|
#PoolSize = 25500;
|
|
|
|
|
EmitRouter = true;
|
|
|
|
|
EmitDNS = true;
|
|
|
|
|
DNS = [
|
|
|
|
|
"1.1.1.1"
|
|
|
|
|
"1.0.0.1"
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
dhcpServerStaticLeases = [
|
|
|
|
|
# IPMI
|
|
|
|
|
{
|
|
|
|
|
dhcpServerStaticLeaseConfig = {
|
|
|
|
|
Address = "10.30.1.1";
|
|
|
|
|
MACAddress = "ac:1f:6b:4b:01:15";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
# paul-fixe
|
|
|
|
|
{
|
|
|
|
|
dhcpServerStaticLeaseConfig = {
|
|
|
|
|
Address = "10.30.50.1";
|
|
|
|
|
MACAddress = "b4:2e:99:ed:24:26";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
# salonled
|
|
|
|
|
{
|
|
|
|
|
dhcpServerStaticLeaseConfig = {
|
|
|
|
|
Address = "10.30.40.1";
|
|
|
|
|
MACAddress = "e0:98:06:85:e9:ce";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
# miroir-bleu
|
|
|
|
|
{
|
|
|
|
|
dhcpServerStaticLeaseConfig = {
|
|
|
|
|
Address = "10.30.40.2";
|
|
|
|
|
MACAddress = "e0:98:06:86:38:fc";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
# miroir-orange
|
|
|
|
|
{
|
|
|
|
|
dhcpServerStaticLeaseConfig = {
|
|
|
|
|
Address = "10.30.40.3";
|
|
|
|
|
MACAddress = "50:02:91:78:be:be";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
];
|
2023-09-15 15:57:00 +02:00
|
|
|
|
ipv6SendRAConfig = {
|
|
|
|
|
EmitDNS = true;
|
|
|
|
|
DNS = [
|
|
|
|
|
"2606:4700:4700::1111"
|
|
|
|
|
"2606:4700:4700::1001"
|
|
|
|
|
];
|
2023-09-15 15:27:47 +02:00
|
|
|
|
};
|
|
|
|
|
};
|
2023-09-21 23:52:56 +02:00
|
|
|
|
"40-enp0s21u1".dhcpV4Config.RouteMetric = 1024;
|
2021-12-20 08:34:21 +01:00
|
|
|
|
};
|
|
|
|
|
|
2018-05-04 15:25:24 +02:00
|
|
|
|
nixpkgs.overlays = [
|
2023-01-05 11:18:09 +01:00
|
|
|
|
(import ../../overlays/transmission.nix)
|
2018-05-04 15:25:24 +02:00
|
|
|
|
];
|
2018-05-07 11:35:57 +02:00
|
|
|
|
|
2018-09-04 14:05:06 +02:00
|
|
|
|
services.openssh = {
|
|
|
|
|
enable = true;
|
2023-06-13 14:05:05 +02:00
|
|
|
|
settings = {
|
|
|
|
|
PermitRootLogin = "no";
|
|
|
|
|
PasswordAuthentication = false;
|
|
|
|
|
X11Forwarding = true;
|
|
|
|
|
};
|
2018-09-04 14:05:06 +02:00
|
|
|
|
};
|
2018-03-31 22:16:38 +02:00
|
|
|
|
|
2020-08-30 16:25:51 +02:00
|
|
|
|
users = {
|
|
|
|
|
groups.autossh = { };
|
|
|
|
|
users.autossh = {
|
|
|
|
|
home = "/home/autossh";
|
|
|
|
|
createHome = true;
|
|
|
|
|
group = "autossh";
|
2021-10-11 10:49:30 +02:00
|
|
|
|
isSystemUser = true;
|
2020-08-30 16:25:51 +02:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2024-02-22 13:33:43 +01:00
|
|
|
|
# Options explanations
|
|
|
|
|
# -N disable shell
|
|
|
|
|
# -R 0.0.0.0:2222:127.0.0.1:22 redirect SSH port on VPS server on port 2222
|
|
|
|
|
# -R 127.0.0.1:2525:127.0.0.1:25 redirect SMTP port on VPS port 2525
|
|
|
|
|
services.autossh.sessions = [
|
|
|
|
|
{
|
2024-05-14 10:38:42 +02:00
|
|
|
|
extraArguments = "-N -R 0.0.0.0:2222:127.0.0.1:22 loutre@vps772619.ovh.net";
|
2024-02-22 13:33:43 +01:00
|
|
|
|
monitoringPort = 20000;
|
|
|
|
|
name = "backup-ssh-reverse";
|
|
|
|
|
user = "autossh";
|
|
|
|
|
}
|
|
|
|
|
];
|
2020-08-30 16:25:51 +02:00
|
|
|
|
|
2021-10-11 10:48:26 +02:00
|
|
|
|
virtualisation.podman.enable = true;
|
|
|
|
|
|
2018-03-31 22:16:38 +02:00
|
|
|
|
security.sudo.wheelNeedsPassword = false;
|
|
|
|
|
|
2018-05-03 00:02:19 +02:00
|
|
|
|
system.stateVersion = "18.03";
|
2018-03-31 22:16:38 +02:00
|
|
|
|
}
|