host/tatos: fix configs
This commit is contained in:
parent
7324c1d1dd
commit
1cec47e1e2
5 changed files with 13 additions and 13 deletions
Binary file not shown.
|
@ -1,5 +1,8 @@
|
||||||
{ ... }:
|
{ ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [ ./wireguard ];
|
imports = [
|
||||||
|
./wireguard
|
||||||
|
./dns.nix
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
let dnsport = 53; in
|
let dnsport = 53; in
|
||||||
{
|
{
|
||||||
services.dnscrypt-proxy2.settings.listen_addresses = [ "[::1]:51" ];
|
services.dnscrypt-proxy2.settings.listen_addresses = [ "127.0.0.1:51" "[::1]:51" ];
|
||||||
|
|
||||||
# Forward loopback traffic on port 53 to dnscrypt-proxy2.
|
# Forward loopback traffic on port 53 to dnscrypt-proxy2.
|
||||||
networking.firewall.extraCommands = ''
|
networking.firewall.extraCommands = ''
|
||||||
|
@ -25,4 +25,4 @@ let dnsport = 53; in
|
||||||
interface = "wg0";
|
interface = "wg0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ let
|
||||||
|
|
||||||
tatosData = import ../../data.secret.nix;
|
tatosData = import ../../data.secret.nix;
|
||||||
port = tatosData.wireguard.port;
|
port = tatosData.wireguard.port;
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
|
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
|
||||||
|
@ -20,20 +19,19 @@ in
|
||||||
internalInterfaces = [ "wg0" ];
|
internalInterfaces = [ "wg0" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
networking.firewall.allowedUDPPorts = [ port ];
|
||||||
|
|
||||||
services.cron =
|
services.cron =
|
||||||
let
|
let update_ru_routes = pkgs.callPackage ./update_ru_routes.nix { }; in
|
||||||
update_ru_routes = pkgs.callPackage ./update_ru_routes.nix { };
|
let cmd = "${update_ru_routes}/bin/update_ru_routes > /root/update_routes.log 2>&1"; in
|
||||||
cmd = "${update_ru_routes}/bin/update_ru_routes > /root/update_routes.log 2>&1";
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
enable = true;
|
enable = true;
|
||||||
systemCronJobs = [
|
systemCronJobs = [
|
||||||
"@reboot sleep 30 && ${cmd}"
|
"@reboot root sleep 30 && ${cmd}"
|
||||||
"0 3 * * mon ${cmd}"
|
"0 3 * * mon root ${cmd}"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
networking.wg-quick.interfaces = {
|
networking.wg-quick.interfaces = {
|
||||||
# "wg0" is the network interface name. You can name the interface arbitrarily.
|
# "wg0" is the network interface name. You can name the interface arbitrarily.
|
||||||
wg0 = {
|
wg0 = {
|
||||||
|
@ -46,13 +44,11 @@ in
|
||||||
# This allows the wireguard server to route your traffic to the internet and hence be like a VPN
|
# This allows the wireguard server to route your traffic to the internet and hence be like a VPN
|
||||||
# For this to work you have to set the dnsserver IP of your router (or dnsserver of choice) in your clients
|
# For this to work you have to set the dnsserver IP of your router (or dnsserver of choice) in your clients
|
||||||
postUp = ''
|
postUp = ''
|
||||||
gateway=`${pkgs.iproute}/bin/ip route | ${pkgs.gawk}/bin/awk '/default/ {print $3; exit}'`
|
|
||||||
interface=`${pkgs.iproute}/bin/ip route | ${pkgs.gawk}/bin/awk '/default/ {print $5; exit}'`
|
interface=`${pkgs.iproute}/bin/ip route | ${pkgs.gawk}/bin/awk '/default/ {print $5; exit}'`
|
||||||
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -o $interface -j MASQUERADE
|
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -o $interface -j MASQUERADE
|
||||||
${pkgs.iproute}/bin/ip rule add from ${tatosData.addr} table main
|
${pkgs.iproute}/bin/ip rule add from ${tatosData.addr} table main
|
||||||
'';
|
'';
|
||||||
preDown = ''
|
preDown = ''
|
||||||
gateway=`${pkgs.iproute}/bin/ip route | ${pkgs.gawk}/bin/awk '/default/ {print $3; exit}'`
|
|
||||||
interface=`${pkgs.iproute}/bin/ip route | ${pkgs.gawk}/bin/awk '/default/ {print $5; exit}'`
|
interface=`${pkgs.iproute}/bin/ip route | ${pkgs.gawk}/bin/awk '/default/ {print $5; exit}'`
|
||||||
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -o $interface -j MASQUERADE
|
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -o $interface -j MASQUERADE
|
||||||
${pkgs.iproute}/bin/ip rule del from ${tatosData.addr} table main
|
${pkgs.iproute}/bin/ip rule del from ${tatosData.addr} table main
|
||||||
|
|
|
@ -20,6 +20,7 @@ interface=`ip route | awk '/default/ {print $5; exit}'`
|
||||||
# Get addresses RU segment
|
# Get addresses RU segment
|
||||||
echo "Add stat.ripe.net to $interface"
|
echo "Add stat.ripe.net to $interface"
|
||||||
ip route add 193.0.6.150/32 via $gateway_for_internal_ip dev $interface
|
ip route add 193.0.6.150/32 via $gateway_for_internal_ip dev $interface
|
||||||
|
|
||||||
echo "Download RU subnets..."
|
echo "Download RU subnets..."
|
||||||
curl --progress-bar "https://stat.ripe.net/data/country-resource-list/data.json?resource=ru" | jq -r ".data.resources.ipv4[]" > $file_raw
|
curl --progress-bar "https://stat.ripe.net/data/country-resource-list/data.json?resource=ru" | jq -r ".data.resources.ipv4[]" > $file_raw
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue