I have 2 network interfaces - 1 connected to internal network and 1 connected to external network, both interfaces acquire their IP from DHCP.
By default traffic goes through internal network and external network should be routed separately through a routing table called "public". I'm trying to achieve this using netplan with the following config:
network:
version: 2
ethernets:
ens3:
dhcp4: yes
dhcp4-overrides:
route-metric: 99
ens4:
dhcp4: yes
dhcp4-overrides:
route-metric: 100
routing-policy:
- from: w.x.y.z
table: 201
- to: w.x.y.z
table: 201
routes:
- to: 0.0.0.0/0
via: w.x.v.1
table: 201
- to: w.x.v.0/23
via: w.x.v.1
table: 201
After i run netplan apply
I'd expect to see the following:
root@my-u18:~# ip route show table 201
default via w.x.v.1 dev ens4
x.y.v.0/23 dev ens4 scope link src w.x.y.z
But in reality the routing table is not populated
root@my-u18:~# ip route show table 201
root@my-u18:~#
However, the routing rules seem to apply:
root@my-u18:~# ip rule
0: from all lookup local
0: from w.x.y.z lookup public
0: from all to w.x.y.z lookup public
32766: from all lookup main
32767: from all lookup default
What am I missing?
Have you added table 201 to
/etc/iproute2/rt_tables
(or/etc/iproute2/rt_tables.d/
)?If you haven't, try adding a file at
/etc/iproute2/rt_tables.d/foo.conf
with the following content:Then run
netplan apply
and see if the routes in 201 show up.