Netplan – Configure two interfaces on same network

netplansystemd-networkd

I have a set of Ubuntu 18.04.5 LTS servers with two interfaces each.
eno1 – 1g management interface
eno5 – 10g data interface

Both interfaces are in the same L2 subnet (10.98.16.0/22). My issue is that I'm unable to use the eno5 (10g) interface to ping other 10g interfaces. So something like ping 10.98.17.11 -I eno5 fails, but I'm able to ping that same address if I use the default eno1 interface.

I was able to fix this by using the following commands:

# Add new routing table
echo 100 t1 >> /etc/iproute2/rt_tables
echo 101 t2 >> /etc/iproute2/rt_tables

#Add routes to tables
ip route add 10.98.16.0/22 dev eno1 src 10.98.17.1 table t1
ip route add table t1 default via 10.98.16.1 dev eno1

ip route add 10.98.16.0/22 dev eno5 src 10.98.17.11 table t2
ip route add table t2 default via 10.98.16.1 dev eno5

# Add rules to routing tables
ip rule add table t1 from 10.98.17.1
ip rule add table t2 from 10.98.17.11


~ ping 10.98.17.13 -I eno5 

PING 10.98.17.13 (10.98.17.13) from 10.98.17.11 eno5: 56(84) bytes of data.
64 bytes from 10.98.17.13: icmp_seq=1 ttl=64 time=0.157 ms

However, I'd like to get this working in Netplan. I'm using the following contents in /etc/netplan/00-network.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
        addresses:
        - 10.98.17.1/22
        routes:
        -   metric: 100
            table: 100
            to: 10.98.16.0/22
            via: 10.98.17.1
    eno5:
        addresses:
        - 10.98.17.11/22
        routes:
        -   metric: 101
            table: 101
            to: 10.98.16.0/22
            via: 10.98.17.11

The interfaces are configured and there are no errors. However, I'm unable to ping. If anyone has an idea of what I'm missing, please let me know!

~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.98.16.0      0.0.0.0         255.255.252.0   U     0      0        0 eno1
10.98.16.0      0.0.0.0         255.255.252.0   U     0      0        0 eno5

Best Answer

adding routing-policy might help

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
        addresses:
        - 10.98.17.1/22
        routes:
        -   metric: 100
            table: 100
            to: 10.98.16.0/22
            via: 10.98.17.1
        routing-policy:
        - from: 10.98.17.1
            table: 100

Related Topic