2

I want to add static route in the netplan yaml file by using netplan set cli. However, it only add "to:", but it doesn't add the "via" and "metric", not sure what is going wrong..

# sudo netplan set --debug --origin-hint 99-netcfg-vmware network.ethernets.ens160.routes=[{'to':' 10.0.0.0/8','via':' 10.74.174.1','metric':' 200'}]
debug:  network:
  ethernets:
    ens160:
      addresses:
      - 10.74.174.27/24
      dhcp4: false
      dhcp6: false
      gateway4: 10.74.174.20
      nameservers:
        addresses:
        - 64.104.76.247
      routes:
      - to: 10.0.0.0/8
    ens224:
      addresses:
      - 10.74.202.228/24
      dhcp4: false
      dhcp6: false
      nameservers:
        addresses:
        - 64.104.76.247
  renderer: networkd
  version: 2

1 Answers1

2

I was having the same problem and I couldn't solve it in any way with the documentation, but I got the answer on the Netplan bug site (https://bugs.launchpad.net/netplan/), another user posted the code and I decided to test and Worked very well. I hope it`s helps you.
netplan set ethernets.eth0.routes='[{"to":"deafult", "via": "192.168.46.2","metric":200}]'

Set cli print

source: https://bugs.launchpad.net/netplan/+bug/1988444

KvB4
  • 21