#!/bin/bash -ex

ip link del eth1 2>/dev/null || true

ip link add eth1 type veth peer name eth1peer || true
ip link set eth1 up
ip link set eth1peer netns tmp
ip netns exec tmp ip link set eth1peer up

nmcli device set eth1 managed yes


echo "
---
routes:
  config:
    - destination: 198.51.100.1
      next-hop-interface: eth1
      table-id: 50
interfaces:
  - name: eth1
    type: ethernet
    state: up
    mtu: 1500
    ipv4:
      enabled: true
      address: []
      dhcp: false
" | nmstatectl set -


echo "
---
interfaces:
  - name: eth1
    state: absent
routes:
  config:
    - state: absent" | nmstatectl set -
