From 5820e7e2573254857f17dab1b839c13cfee442d1 Mon Sep 17 00:00:00 2001 From: Evan Cassidy Date: Mon, 4 Sep 2023 17:49:33 +0000 Subject: [PATCH 1/4] routing for second interface --- machines/skynet.nix | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/machines/skynet.nix b/machines/skynet.nix index 51d7dc9..b8a9dab 100644 --- a/machines/skynet.nix +++ b/machines/skynet.nix @@ -81,4 +81,31 @@ in { name = name; }; }; -} \ No newline at end of file + # + networking = { + iproute2 = { + enable = true; + rttablesExtraConfig = + ''1 rt2''; + }; + }; + + systemd.services.secondGateway = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + description = "External route."; + path = [pkgs.bash pkgs.iproute]; + script = '' + ip route add 193.1.96.160/28 dev eth1 src 193.1.96.165 table rt2 + ip route add default via 193.1.96.165 dev eth1 table rt2 + ip rule add from 193.1.96.165/28 table rt2 + ip rule add to 193.1.96.165/28 table rt2 + ''; + serviceConfig = { + Type= "oneshot"; + User = "root"; + Restart = "no"; + }; + }; + +} -- 2.46.1 From b3c23d1621a95efd0de2c463e4bdf3e7739e825b Mon Sep 17 00:00:00 2001 From: Evan Cassidy Date: Mon, 4 Sep 2023 17:50:43 +0000 Subject: [PATCH 2/4] I don't think we need those two bits --- machines/skynet.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/machines/skynet.nix b/machines/skynet.nix index b8a9dab..a3f8095 100644 --- a/machines/skynet.nix +++ b/machines/skynet.nix @@ -91,8 +91,6 @@ in { }; systemd.services.secondGateway = { - wantedBy = [ "multi-user.target" ]; - after = [ "network.target" ]; description = "External route."; path = [pkgs.bash pkgs.iproute]; script = '' -- 2.46.1 From caf5b4291e98fd156bb31f292ef1419c9e5a7eb2 Mon Sep 17 00:00:00 2001 From: Evan Cassidy Date: Mon, 4 Sep 2023 17:51:17 +0000 Subject: [PATCH 3/4] sources --- machines/skynet.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/machines/skynet.nix b/machines/skynet.nix index a3f8095..dc1da5f 100644 --- a/machines/skynet.nix +++ b/machines/skynet.nix @@ -81,7 +81,8 @@ in { name = name; }; }; - # + + # from https://discourse.nixos.org/t/second-default-gateway/22220/5 and https://www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System networking = { iproute2 = { enable = true; -- 2.46.1 From 127cd52258722ebaa3f23a0e457d3486b678e644 Mon Sep 17 00:00:00 2001 From: Evan Cassidy Date: Mon, 4 Sep 2023 18:31:40 +0000 Subject: [PATCH 4/4] typo --- machines/skynet.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machines/skynet.nix b/machines/skynet.nix index dc1da5f..2bb7c0a 100644 --- a/machines/skynet.nix +++ b/machines/skynet.nix @@ -96,7 +96,7 @@ in { path = [pkgs.bash pkgs.iproute]; script = '' ip route add 193.1.96.160/28 dev eth1 src 193.1.96.165 table rt2 - ip route add default via 193.1.96.165 dev eth1 table rt2 + ip route add default via 193.1.96.161 dev eth1 table rt2 ip rule add from 193.1.96.165/28 table rt2 ip rule add to 193.1.96.165/28 table rt2 ''; -- 2.46.1