Installation
Alpine Linux
IfState is available in the community repository since Alpine Linux 3.13.
If the wireguard-tools-wg package is going to be installed it will pull also py3-wgnlpy which enables Wireguard support in Ifstate.
To enable eXpress Data Path (XDP) support you need to install libbpf.
You need to install py3-pygments to enable syntax highlighting in ifstate's interactive python shell.
NixOS
Downstream Nixpkgs
IfState is available in Nixpkgs repository since NixOS 25.11.
See NixOS Search for all available options.
Additionally this module also supports IfState to be used in the initrd to accomplish features like remote disk decryption using ssh.
Example Configuration
{
networking.ifstate = {
enable = true;
settings = {
interfaces.eth0 = {
addresses = [ "2001:0db8::10/64" ];
link = {
state = "up";
kind = "physical";
};
identify.perm_address = "2e:28:00:60:c2:1b";
};
routing.routes = [
{ to = "::/0"; via = "2001:0db8::1"; }
];
};
};
}
Example initrd Configuration
{ config, ... }:
{
boot.initrd = {
# systemd stage two is required for IfState in initrd
system.enable = true;
network = {
enable = true;
ifstate = {
enable = true;
# copy non-initrd ifstate configuration
# NOTE: ifstate in initrd disables some features by default
# in order to redurce disk usage in /boot
# see `boot.initrd.network.ifstate.package` for details.
settings = config.networking.ifstate.settings;
};
# example ssh configuration
# See https://wiki.nixos.org/wiki/Remote_disk_unlocking for details
# after connecting to ssh execute `systemctl default`
ssh = {
enable = true;
hostKeys = [ /etc/ssh/ssh_initrd_host_ed25519_key ];
authorizedKeys = [ "ssh-ed25519 AAAA..." ];
};
};
};
}
Using IfState as a flake
This repository can also be used as a flake input:
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
ifstate = {
url = "git+https://codeberg.org/routerkit/ifstate";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, ifstate, ... }: {
nixosConfigurations = {
hostname = nixpkgs.lib.nixosSystem {
modules = [
ifstate.nixosModules.default
];
};
};
};
}
The supported options are identical, but may contain new features ahead of schedule.
Manually
Prerequisites
IfState depends on Python3 and the following python packages:
- pyroute2 - Python Netlink library
- PyYAML - YAML parser and emitter for Python
- jsonschema - An implementation of JSON Schema validation for Python (recommended)
- wgnlpy - Python netlink connector to WireGuard (optional)
- Pygments - Python syntax highlighter (optional)
IfState uses python ctypes to configure XDP. You need to have libbp.so.1 available to configure XDP.
PyPI
IfState is available at Python Package Index. Use pip3 for installation:
This will also install all dependencies if not already satisfied. The optional dependencies can be installed via pip's extra feature: