IfState: Difference between revisions
m diagram: fix format again |
m Change link to current site wiki |
||
| (4 intermediate revisions by one other user not shown) | |||
| Line 4: | Line 4: | ||
=== Examples === | === Examples === | ||
You can find several examples on the [https://ifstate.net/2. | You can find several examples on the [https://ifstate.net/2.2/examples/ IfState website]. Some include NixOS configuration instructions, while the more complex examples are covered in detail here. | ||
==== Network Namespaces (netns) ==== | ==== Network Namespaces (netns) ==== | ||
| Line 15: | Line 15: | ||
systemd.services."<name>".serviceConfig.NetworkNamespacePath = "/var/run/netns/<netnsName>"; | systemd.services."<name>".serviceConfig.NetworkNamespacePath = "/var/run/netns/<netnsName>"; | ||
} | } | ||
</syntaxhighlight>When using [ | </syntaxhighlight>When using [[NixOS Containers|nixos-containers]], network namespaces allow you to configure the network outside the container. This separation simplifies management and ensures the container’s network setup is independent of its internal configuration.<syntaxhighlight lang="nixos"> | ||
{ | { | ||
containers."<name>".networkNamespace = "/var/run/netns/<netnsName>"; | containers."<name>".networkNamespace = "/var/run/netns/<netnsName>"; | ||
| Line 164: | Line 164: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==== DHCPv4 ==== | |||
<syntaxhighlight lang="nixos"> | |||
{ lib, pkgs, ... }: | |||
{ | |||
networking.ifstate = { | |||
enable = true; | |||
settings = { | |||
parameters.hooks.dhcp.script = pkgs.writeScript "ifstate-udhcp-wrapper-script.sh" '' | |||
${lib.getExe' pkgs.busybox "udhcpc"} --quit --now -i $IFS_IFNAME -b --script ${pkgs.busybox}/default.script | |||
''; | |||
interfaces.eth1 = { | |||
addresses = [ ]; | |||
hooks = [ | |||
{ name = "dhcp"; } | |||
]; | |||
link = { | |||
state = "up"; | |||
kind = "physical"; | |||
}; | |||
}; | |||
}; | |||
}; | |||
} | |||
</syntaxhighlight> | |||
=== Known Issues === | === Known Issues === | ||