4

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
  • 41
  • 1
  • 2

2 Answers2

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
0

I use Debian 11 but Ubuntu is a Debian derivative so I expect the issue is similar.

In Debian 11 this is due to bugs in netplan.io.

netplan.io version 0.101-4 (default in Debian 11) is buggy and does not populate policy route tables.

Version 0.105-2 (available from Debian testing repo) works correctly. However this also pulls in a number of dependencies from the testing repo, which could be risky.

Ubuntu 20.04 distro has a netplan.io 0.104-0 update which can be installed on Debian 11 without pulling other dependencies:

wget http://archive.ubuntu.com/ubuntu/pool/main/n/netplan.io/netplan.io_0.104-0ubuntu2~20.04.2_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/main/n/netplan.io/libnetplan0_0.104-0ubuntu2~20.04.2_amd64.deb
sudo apt install ./netplan.io_0.104-0ubuntu2~20.04.2_amd64.deb ./libnetplan0_0.104-0ubuntu2~20.04.2_amd64.deb
kevind
  • 1
  • 1