summaryrefslogtreecommitdiff
path: root/config/networking
diff options
context:
space:
mode:
Diffstat (limited to 'config/networking')
-rw-r--r--config/networking/bridges.nix15
-rw-r--r--config/networking/default.nix2
-rw-r--r--config/networking/services/default.nix7
-rw-r--r--config/networking/services/ifplugd.nix37
4 files changed, 40 insertions, 21 deletions
diff --git a/config/networking/bridges.nix b/config/networking/bridges.nix
index d8cd9e7..e423e03 100644
--- a/config/networking/bridges.nix
+++ b/config/networking/bridges.nix
@@ -12,21 +12,6 @@ in {
sleep 3
'');
}
- {
- # create a bridge on top of enp3s0 along with a dummy interface
- # for kea to work even when enp3s0 is disconnected
- # if you change this, you may want to change:
- # - the kea configuration in ./services/dhcp.nix
- # - the eth0 net configuration ./default.nix
- networking = {
- bridges.eth0.interfaces = ["enp3s0" "enp3s0-dummy"];
- localCommands = ''
- ip link add enp3s0-dummy type dummy
- '';
- };
- boot.kernelModules = ["dummy"];
- systemd.services.network-addresses-enp3s0-dummy.enable = false;
- }
]
++ (builtins.map (network: let
bridge = network.interface;
diff --git a/config/networking/default.nix b/config/networking/default.nix
index 7ffc32b..81efaf2 100644
--- a/config/networking/default.nix
+++ b/config/networking/default.nix
@@ -95,7 +95,7 @@ in {
};
eth0 = {
device = "enp3s0";
- interface = "eth0";
+ interface = "enp3s0";
subnet = "192.168.4";
machines = {
self.ip = "192.168.4.1";
diff --git a/config/networking/services/default.nix b/config/networking/services/default.nix
index 0ec9540..623a1c7 100644
--- a/config/networking/services/default.nix
+++ b/config/networking/services/default.nix
@@ -1,6 +1,3 @@
-{ ... }:
-
-{
- imports =
- [ ./ap.nix ./dhcp.nix ./dns.nix ./firewall ./igmpproxy.nix ];
+{...}: {
+ imports = [./ap.nix ./dhcp.nix ./dns.nix ./firewall ./ifplugd.nix ./igmpproxy.nix];
}
diff --git a/config/networking/services/ifplugd.nix b/config/networking/services/ifplugd.nix
new file mode 100644
index 0000000..4933b97
--- /dev/null
+++ b/config/networking/services/ifplugd.nix
@@ -0,0 +1,37 @@
+{
+ config,
+ pkgs,
+ ...
+}: let
+ iface = config.personal.networking.networks.eth0.device;
+ dhcpService = "kea-dhcp4-server.service";
+ action = pkgs.writeShellApplication {
+ name = "ifplugd-enp3s0.action";
+ runtimeInputs = [pkgs.systemd];
+ text = ''
+ INTERFACE="$1"
+ EVENT="$2"
+
+ if [[ "$INTERFACE" == '${iface}' && "$EVENT" == up ]]
+ then
+ echo ${iface} went up, restarting ${dhcpService}...
+ systemctl restart ${dhcpService}
+ fi
+ '';
+ };
+in {
+ systemd.services."ifplugd-${iface}" = {
+ enable = true;
+
+ description = "Monitor status of interface ${iface}";
+ after = ["sys-subsystem-net-devices-${iface}.device" dhcpService];
+ wantedBy = [dhcpService];
+
+ script = ''
+ # iface no-daemon no-auto no-shutdown delay-up run
+ ifplugd -i ${iface} -n -a -q -u 5 -r \
+ ${action}/bin/ifplugd-enp3s0.action
+ '';
+ path = [pkgs.busybox];
+ };
+}