Nmstate

A Declarative API for Host Network Management

View on GitHub

The nmstatectl User Guide

The nmstatectl is created for users who want to try out nmstate without using libnmstate.

For detail information about network state format and definition, please refer to the API document.

Query Network State

To query current network state, please use the following command:

nmstatectl show [<interface_name>]

YAML is the default output format. Use the --json argument to change the output format to JSON.

To limit the output state to include certain interfaces only, please specify the interface name as nmstatectl show <interface_names>. Please be advised, global config like DNS will be included.

For multiple interface names, use comma to separate them. You can also use patterns for interface names:

*       matches everything
?       matches any single character
[seq]   matches any character in seq
[!seq]  matches any char not in seq

For example, to show all interfaces starts with eth:

nmstatectl show eth\*
# The backslash is required to stop shell expanding '*' to file names.

Change Network State

The network state may be changed interactively or by file:

By default, if the network state after state applied is not identical to the desired state, nmstatectl rollbacks to the state before edit/set command. Use the --no-verify argument to skip the verification.

Manual Transaction Control

The nmstatectl supports manual transaction control which allows user to decide whether rollback to previous(before nmstatectl apply) state.

This command will create a checkpoint which later could be used for rollback or commit.

nmstatectl apply --no-commit [--timeout <TIMEOUT>]

The checkpoint string will be the last line of nmstatectl output, example: /org/freedesktop/NetworkManager/Checkpoint/1.

The network state will be applied to OS but allow user to decide whether rollback or commit.

To rollback: nmstatectl rollback <checkpoint_path>.

To commit: nmstatectl commit <checkpoint_path>.

The user must commit the changes within TIMEOUT(default is 60 seconds), or they will be automatically rolled back.