Skip to content

Instantly share code, notes, and snippets.

@rajeshrah22
Last active July 22, 2025 19:04
Show Gist options
  • Select an option

  • Save rajeshrah22/405c64245668a5c2d22abff497394388 to your computer and use it in GitHub Desktop.

Select an option

Save rajeshrah22/405c64245668a5c2d22abff497394388 to your computer and use it in GitHub Desktop.
Reproduces the ip address appending problem with nmstate.
read -r -d '' ETH1 <<EOF
interfaces:
- name: eth1
type: ethernet
state: up
ipv4:
address:
- ip: 192.0.2.1
prefix-length: 24
dhcp: false
enabled: true
ipv6:
address:
- ip: 2001:db8:1::1
prefix-length: 64
dhcp: false
enabled: true
autoconf: false
EOF
read -r -d '' ETH1_CHANGED_IP <<EOF
interfaces:
- name: eth1
type: ethernet
state: up
ipv4:
address:
- ip: 192.0.2.2
prefix-length: 24
dhcp: false
enabled: true
ipv6:
address:
- ip: 2001:db8:1::2
prefix-length: 64
dhcp: false
enabled: true
autoconf: false
EOF
setup_eth1() {
sudo ip link add eth1 type veth peer eth1_p
sudo ip link set eth1 up
sudo ip link set eth1_p up
}
cleanup_eth1() {
sudo ip link delete eth1
}
main() {
sudo systemctl stop NetworkManager
setup_eth1
echo "$ETH1" | sudo ./rust/target/debug/nmstatectl apply -k -
echo "sleeping 1 second ..."
sleep 1
echo "$ETH1_CHANGED_IP" | sudo ./rust/target/debug/nmstatectl apply -k -
echo "sleeping 1 second ..."
sleep 1
ip a show eth1
./rust/target/debug/nmstatectl show eth1 -k
cleanup_eth1
}
main
@rajeshrah22
Copy link
Author

Pre-requisites:

  • rust toolchain
  • nmstate source code
git clone https://github.com/nmstate/nmstate.git
cd nmstate
cd rust; cargo build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment