Last active
July 22, 2025 19:04
-
-
Save rajeshrah22/405c64245668a5c2d22abff497394388 to your computer and use it in GitHub Desktop.
Reproduces the ip address appending problem with nmstate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pre-requisites: