I have an Ubuntu 18.04 host with two network interfaces on two subnets. I would like to set up symmetric routing so that traffic received from one interface is sent symmetrically out that same interface.

I know how to use Netplan for simple network configurations, but I'm stumped for more advanced configurations. Specifically:

  1. What is the Netplan syntax to add a default route like I do with ip route add default via dev ens192 tab 1?
  2. How can I add a priority tag to a route?

My server has two IPs:

$ ip a|grep "inet "
inet scope host lo
inet brd scope global ens192
inet brd scope global ens224

I can use the following ip rules to get the tables that I want:

First, I create a route for each network and then add a default gateway.

$ ip route add dev ens192 tab 1
$ ip route add dev ens224 tab 2
$ ip route add default via dev ens192 tab 1
$ ip route add default via dev ens224 tab 2

Then, I can create corresponding rules:

$ ip rule add from tab 1 priority 100
$ ip rule add from tab 2 priority 200
$ ip route flush cache

This gets the routes that I want:

$ ip route show tab 1
default via dev ens192
$ ip route show tab 2
default via dev ens224
$ ip route
default via dev ens192

As well as the rules that I want:

$ ip rule show
0:      from all lookup local
100:    from lookup 1
200:    from lookup 2
32766:  from all lookup main
32767:  from all lookup default

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.