I recently upgraded to ubuntu 18.04 from 16.04 and am trying to figure out how to get my ip route
and ip rule
commands that I used to put in /etc/network/interfaces
working under netplan.
These are the commands that I'm trying to reproduce, that I previously ran in /etc/network/interfaces
:
sudo ip rule add table 129 from 192.168.1.160
sudo ip route add table 129 to 204.8.230.0/24 dev enp0s3
sudo ip route add table 129 to 192.168.1.0/24 dev enp0s3
sudo ip route add table 129 default via 192.168.1.1
This is my first pass at the netplan config in /etc/netplan/01-netcfg.yaml
:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
routes:
- from: 192.168.1.160
to: 204.8.230.0/24
via: 192.168.1.1
- from: 192.168.1.160
to: 192.168.1.0/24
via: 192.168.1.1
However, after a restart those routes do not show up in the ip route
output. How do I get these routes to stick?
Note that I've also tried putting these commands in a script in /usr/lib/networkd-dispatcher/routable.d
based on some documentation I found, but that does not appear to have worked either.
EDIT: I'm getting closer. This is the new config, but now the problem is that although the table shows up in ip rule
, ip route show table 129
is empty:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
routing-policy:
- from: 192.168.1.160
table: 129
routes:
- to: 204.8.230.0/24
via: 192.168.1.1
table: 129
- to: 192.168.1.0/24
via: 192.168.1.1
table: 129
- to: 0.0.0.0/0
via: 192.168.1.1
table: 129
I'm on netplan version 0.36.1