0

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

auto enp0s8
iface enp0s8 inet static
address 192.168.0.5
netmask 255.255.255.0
up route add -host 192.168.0.100 dev enp0s8
up route add -host 192.168.0.101 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.

network:
    ethernets:
        enp0s8:
            dhcp4: no
            addresses: [192.168.0.5/24]
            routes:
            - to: 192.168.0.101
              via: 192.168.0.101
    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?

1

Your static IP is on 192.168.0.0/24 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.