Skip to content

Instantly share code, notes, and snippets.

@rajeshrah22
Created August 14, 2025 01:39
Show Gist options
  • Select an option

  • Save rajeshrah22/7cacbc2422745085e3afbe41324ba5ec to your computer and use it in GitHub Desktop.

Select an option

Save rajeshrah22/7cacbc2422745085e3afbe41324ba5ec to your computer and use it in GitHub Desktop.
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.1
prefix-length: 12
dhcp: false
enabled: true
ipv6:
address:
- ip: 2001:db8:1::1
prefix-length: 32
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
sudo systemctl start NetworkManager
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment