I'm migrating from 16.04 where I had several NICs configured in /etc/network/interfaces like this:

auto enp0s8
iface enp0s8 inet static
up route add -host dev enp0s8
up route add -host dev enp0s8

My only goal is to create a route from that NIC to those IP's using the specified NIC. This is for software that pulls data from the devices' assigned to those IP's. The static route is necessary because the default route is on a different subnet and NIC.

But I am unable to figure out how to do this using Netplan.

            dhcp4: no
            addresses: []
            - to:
    version: 2

Netplan's routes seems to always require via but in my case that won't make sense because via would be the same as to.

How can this by achieved using Netplan?


Your static IP is on network. Target host is on the same network. You don't need to specify static route. There will be a route by default to this network using your enp0s8 interface.

You will need via if you want to specify an IP from a different network.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.