2021-02-08 13:42:35 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2021-03-30 14:01:53 +02:00
|
|
|
let password = builtins.readFile /var/keys/ddclient;
|
|
|
|
|
|
|
|
in {
|
2021-03-12 12:06:26 +01:00
|
|
|
# Assign a static IP
|
|
|
|
networking = {
|
2021-03-15 10:40:49 +01:00
|
|
|
hostName = "unit";
|
|
|
|
hostId = "737d82f4";
|
2021-03-12 12:06:26 +01:00
|
|
|
interfaces.eth0 = {
|
|
|
|
useDHCP = false;
|
2021-03-15 10:40:49 +01:00
|
|
|
ipv4.addresses = [{
|
2021-03-12 12:06:26 +01:00
|
|
|
address = "10.0.1.3";
|
|
|
|
prefixLength = 24;
|
2021-03-15 10:40:49 +01:00
|
|
|
}];
|
2021-03-12 12:06:26 +01:00
|
|
|
};
|
|
|
|
defaultGateway = {
|
|
|
|
address = "10.0.1.1";
|
|
|
|
interface = "eth0";
|
|
|
|
};
|
|
|
|
nameservers = [ "1.1.1.1" "8.8.8.8" ];
|
|
|
|
enableIPv6 = false;
|
|
|
|
};
|
|
|
|
|
2021-02-08 13:42:35 +01:00
|
|
|
# Enable zeroconf
|
|
|
|
services.avahi = {
|
|
|
|
enable = true;
|
|
|
|
nssmdns = true;
|
|
|
|
publish = {
|
|
|
|
enable = true;
|
2021-03-25 09:52:43 +01:00
|
|
|
addresses = true;
|
2021-02-08 13:42:35 +01:00
|
|
|
domain = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-03-30 14:01:53 +02:00
|
|
|
# Dynamic DNS configuration
|
|
|
|
services.ddclient = {
|
|
|
|
enable = true;
|
|
|
|
quiet = true;
|
|
|
|
protocol = "duckdns";
|
|
|
|
domains = [ "coace.duckdns.org" ];
|
|
|
|
inherit password;
|
|
|
|
};
|
|
|
|
|
2021-02-08 13:42:35 +01:00
|
|
|
# Firewall configuration
|
|
|
|
networking.firewall = {
|
2021-03-12 12:06:26 +01:00
|
|
|
allowedTCPPorts = [
|
|
|
|
445 # Samba
|
|
|
|
139 # Samba
|
2021-03-25 09:52:43 +01:00
|
|
|
2222 # VM SSH
|
2021-03-19 11:13:25 +01:00
|
|
|
5000 # Sybase
|
2021-04-07 13:18:31 +02:00
|
|
|
80 # HTTP
|
|
|
|
443 # HTTPS
|
2021-04-14 14:09:17 +02:00
|
|
|
53 # DNS
|
2021-03-12 12:06:26 +01:00
|
|
|
];
|
|
|
|
allowedUDPPorts = [
|
|
|
|
137 # Samba
|
|
|
|
138 # Samba
|
|
|
|
1194 # Wireguard
|
2021-04-14 14:09:17 +02:00
|
|
|
53 # DNS
|
2021-03-12 12:06:26 +01:00
|
|
|
];
|
2021-03-19 11:13:25 +01:00
|
|
|
allowPing = true;
|
2021-02-08 13:42:35 +01:00
|
|
|
};
|
|
|
|
|
2021-03-25 09:52:43 +01:00
|
|
|
# Enable NAT for wireguard and forward ports to sica VM
|
2021-03-12 12:08:22 +01:00
|
|
|
networking.nat = {
|
|
|
|
enable = true;
|
|
|
|
externalInterface = "eth0";
|
2021-03-25 09:52:43 +01:00
|
|
|
internalInterfaces = [ "wg0" "br0" ];
|
|
|
|
forwardPorts = [
|
|
|
|
{
|
|
|
|
destination = "192.168.122.100:22";
|
|
|
|
sourcePort = 2222;
|
2021-03-25 16:35:04 +01:00
|
|
|
loopbackIPs = [ "10.0.1.3" ];
|
2021-03-25 09:52:43 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
destination = "192.168.122.100:5000";
|
|
|
|
sourcePort = 5000;
|
2021-03-25 16:35:04 +01:00
|
|
|
loopbackIPs = [ "10.0.1.3" ];
|
2021-03-25 09:52:43 +01:00
|
|
|
}
|
|
|
|
];
|
2021-03-12 12:08:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# Wireguard setup
|
|
|
|
networking.wireguard.interfaces = {
|
|
|
|
wg0 = {
|
|
|
|
ips = [ "10.9.0.1/24" ];
|
|
|
|
listenPort = 1194;
|
2021-03-30 17:13:34 +02:00
|
|
|
privateKeyFile = "/home/coace/.wg/server/privatekey";
|
2021-03-12 12:08:22 +01:00
|
|
|
peers = [
|
2021-03-30 17:13:34 +02:00
|
|
|
# panacea
|
2021-03-12 12:08:22 +01:00
|
|
|
{
|
|
|
|
publicKey = "XMkTztU2Y8hw6Fu/2o4Gszij+EmNacvFMXuZyHS1n38=";
|
|
|
|
allowedIPs = [ "10.9.0.2/32" ];
|
|
|
|
}
|
2021-03-30 17:13:34 +02:00
|
|
|
# caravanserai
|
|
|
|
{
|
|
|
|
publicKey = "4jiEKaPjNPU3JghfwLyArRhCKZmT8VYN07iw0SL/eHc=";
|
|
|
|
allowedIPs = [ "10.9.0.3/32" ];
|
|
|
|
}
|
2021-03-31 12:33:51 +02:00
|
|
|
# fernando
|
|
|
|
{
|
|
|
|
publicKey = "5DU9ipxJcut2wKrUr3yQux9crzXMSW4ZeKWFLRpUc1I=";
|
|
|
|
allowedIPs = [ "10.9.0.4/32" ];
|
|
|
|
}
|
2021-03-12 12:08:22 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-03-25 09:52:43 +01:00
|
|
|
# QEMU virtual bridge
|
|
|
|
networking.interfaces.br0 = {
|
|
|
|
ipv4.addresses = [{
|
|
|
|
address = "192.168.122.1";
|
|
|
|
prefixLength = 24;
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
networking.bridges.br0.interfaces = [ ];
|
|
|
|
|
|
|
|
services.dhcpd4 = {
|
|
|
|
enable = true;
|
|
|
|
interfaces = [ "br0" ];
|
|
|
|
extraConfig = ''
|
|
|
|
option routers 192.168.122.1;
|
|
|
|
option broadcast-address 192.168.122.255;
|
|
|
|
option subnet-mask 255.255.255.0;
|
|
|
|
option domain-name-servers 1.1.1.1, 8.8.8.8;
|
|
|
|
default-lease-time -1;
|
|
|
|
max-lease-time -1;
|
|
|
|
subnet 192.168.122.0 netmask 255.255.255.0 {
|
|
|
|
range 192.168.122.100 192.168.122.200;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-04-14 14:09:17 +02:00
|
|
|
# DNS server with adblock
|
|
|
|
services.dnsmasq = {
|
|
|
|
enable = true;
|
|
|
|
servers = [ "1.1.1.1" "8.8.8.8" ];
|
|
|
|
extraConfig = ''
|
|
|
|
domain-needed
|
|
|
|
bogus-priv
|
|
|
|
no-resolv
|
|
|
|
|
|
|
|
listen-address=127.0.0.1,10.0.1.3
|
|
|
|
bind-interfaces
|
|
|
|
|
|
|
|
cache-size=10000
|
|
|
|
local-ttl=300
|
|
|
|
|
|
|
|
conf-file=/var/lib/dnsmasq/dnsmasq.blacklist.txt
|
|
|
|
|
|
|
|
address=/coace.duckdns.org/10.0.1.3
|
2021-06-25 15:09:27 +02:00
|
|
|
# Mail server records
|
|
|
|
address=/mail.coace.duckdns.org/10.0.1.3
|
|
|
|
host-record=mail.coace.duckdns.org,10.0.1.3
|
|
|
|
mx-host=coace.duckdns.org,mail.coace.duckdns.org,10
|
|
|
|
server=/47.61.216.88.in-addr.arpa/10.0.1.3
|
|
|
|
ptr-record=47.61.216.88.in-addr.arpa,mail.coace.ducknds.org
|
|
|
|
ptr-record=47.61.216.88.in-addr.arpa,coace.ducknds.org
|
|
|
|
txt-record=coace.duckdns.org,"v=spf1 a:mail.coace.duckdns.org -all"
|
|
|
|
txt-record=mail._domainkey.coace.duckdns.org,"v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDGGeUul/gHC0VMajW6ReX4LH1oo9s52ath/UsvwMdb5vuA0FSjlTellSeP944MkEUt+EY8d64NRrV06+RipeGKweZNNGRybdefvGW2LlmJX0I6MIA6SD3hRPA1CYoX0boHKMAyjrBAzqZmhAXRZNro2nO1H0hCaHriOSH1ru4CYQIDAQAB"
|
|
|
|
txt-record=_dmarc.coace.duckdns.org,"v=DMARC1; p=none"
|
2021-04-14 14:09:17 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-02-08 13:42:35 +01:00
|
|
|
}
|