Add route using netplan

2025-07-22 linux

Using route command:

route add -net 172.17.0.0/16 gw 192.168.250.254 dev eth1
route add -net 192.168.0.0/16 gw 192.168.250.254 dev eth1

Writing on config file(/etc/netplan/01-foo.yaml):

network:
  version: 2
  renderer: networkd
  ethernets:
    eth1:
      addresses:
        - 192.168.1.10/24
      routes:
        - to: 192.168.2.0/16
          via: 192.168.250.254
        - to: 172.17.0.0/16
          via: 192.168.250.254