Ubuntu 17.10 adding multiple static routes for NIC with Netplan
7,644
Solution 1
So it turns out the second option IS actually correct. I just had to restart a couple of times before it started working. Strange. Use this syntax:
network:
version: 2
renderer: networkd
ethernets:
ens3:
dhcp4: yes
eno2:
dhcp4: no
dhcp6: no
addresses: [10.10.0.11/24]
gateway4: 10.10.0.4
routes:
- to: 192.168.1.0/24
via: 10.10.0.4
- to: 192.168.10.0/24
via: 10.10.0.4
Solution 2
After making changes, do the following to get it to take immediately:
sudo netplan apply
Related videos on Youtube
Author by
Sinmok
Updated on September 18, 2022Comments
-
Sinmok over 1 year
I'm trying to add two static routes to my NIC. I can add one OK, but if I try to add a second, the entire network connection stops working until I bring down the 2nd card.
This is my current config which works:
network: version: 2 renderer: networkd ethernets: ens3: dhcp4: yes eno2: dhcp4: no dhcp6: no addresses: [10.10.0.11/24] gateway4: 10.10.0.4 routes: - to: 192.168.1.0/24 via: 10.10.0.4
But I need to add another route to
192.168.10.0/24
by the same gateway10.10.0.4
I have tried to add multiple IPs to the same route such as:
network: version: 2 renderer: networkd ethernets: ens3: dhcp4: yes eno2: dhcp4: no dhcp6: no addresses: [10.10.0.11/24] gateway4: 10.10.0.4 routes: - to: [192.168.1.0/24, 192.168.10.0/24] via: 10.10.0.4
and
network: version: 2 renderer: networkd ethernets: ens3: dhcp4: yes eno2: dhcp4: no dhcp6: no addresses: [10.10.0.11/24] gateway4: 10.10.0.4 routes: - to: 192.168.1.0/24 via: 10.10.0.4 - to: 192.168.10.0/24 via: 10.10.0.4
But both the above causes the network to fail. How do I have to format this so that I can have two static routes?