IfState: Difference between revisions
Appearance
ifstate: init with simple example |
m ifstate: switch to documentation mac address (see https://ittavern.com/dummy-ip-and-mac-addresses-for-documentation-and-sanitization/), add ipv6 documentation prefix |
||
Line 10: | Line 10: | ||
settings = { | settings = { | ||
interfaces.enp3s0 = { | interfaces.enp3s0 = { | ||
addresses = [ "192.0.2.10/24" ]; | addresses = [ | ||
"192.0.2.10/24" | |||
"2001:db8:dead:c0de:200:5eff:fe00:5300/64" | |||
]; | |||
link = { | link = { | ||
state = "up"; | state = "up"; | ||
kind = "physical"; | kind = "physical"; | ||
}; | }; | ||
identify.address = " | identify.address = "00:00:5e:00:53:00"; | ||
}; | }; | ||
routing.routes = [ | routing.routes = [ | ||
Line 22: | Line 25: | ||
dev = "enp3s0"; | dev = "enp3s0"; | ||
via = "192.0.2.1"; | via = "192.0.2.1"; | ||
} | |||
{ | |||
to = "::/0"; | |||
dev = "enp3s0"; | |||
via = "fe80::1"; | |||
} | } | ||
]; | ]; |
Revision as of 19:36, 12 August 2025
IfState is a python 3 utility designed for declarative management of Linux network interfaces. It acts as a frontend to the kernel's Netlink interface, using the pyroute2
library to configure network settings such as IP addresses, bridges, traffic control, and WireGuard in an idempotent manner—much like an iproute2
/ethtool
/tc
/wg
wrapper.
It will be probably be available with NixOS 25.11 (see https://github.com/NixOS/nixpkgs/pull/431047).
Examples
You can find several examples on the IfState website. Due to the fact that these are yaml examples, I decided to provide some nix examples here too:
{
networking.ifstate = {
enable = true;
settings = {
interfaces.enp3s0 = {
addresses = [
"192.0.2.10/24"
"2001:db8:dead:c0de:200:5eff:fe00:5300/64"
];
link = {
state = "up";
kind = "physical";
};
identify.address = "00:00:5e:00:53:00";
};
routing.routes = [
{
to = "0.0.0.0/0";
dev = "enp3s0";
via = "192.0.2.1";
}
{
to = "::/0";
dev = "enp3s0";
via = "fe80::1";
}
];
};
};
}