3

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?

rsoome
  • 31
  • 2

1 Answers1

0

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:

201    foo

Then run netplan apply and see if the routes in 201 show up.

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://serverfault.com/help/whats-reputation) you will be able to [comment on any post](https://serverfault.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/501964) – djdomi Nov 06 '21 at 18:23
  • It should not be necessary to apply the table to `/etc/iproute2/rt_tables`. When Netplan is called at boot time (or when `netplan apply` is run), Netplan should call apply the routing tables at that time. – Stefan Lasiewski Jul 08 '22 at 00:08