NetworkManager with policy-based routing and static routes

I have setup a policy-based routing using nmcli, but I am having trouble to add a static route to the main routing table (254)



routing-rule1=priority 10 from iif ens192 table 100
routing-rule2=priority 10 from table 100




The policy-based routing works. But is not installed to the main routing table.

1 Like

I would add a route with:

nmcli connection modify idn +ipv4.routes ""

(if I wasn’t using Ansible role to do the config)

This command will add the route to route table 100, not the main routing table.

I do get rules to main with that and my main isn’t 254.

# ip ru
0:	from all lookup local
32766:	from all lookup main
32767:	from all lookup default

I believe 32766 is the priority, not the routing table number.

You are correct on that.

$ cat /etc/iproute2/rt_tables
# reserved values
255	local
254	main
253	default
0	unspec
# local
#1	inr.ruhep

Nevertheless, on my systems ipv4.routes "" does go to main.

man nm-settingswrites:

A list of IPv4 destination addresses, prefix length, optional IPv4 next hop addresses, optional route metric, optional attribute. The valid syntax is: “ip[/prefix] [next-hop] [metric] [attribute=val]...[,ip[/prefix]...]”. For example “ 77,”.

Various attributes are supported:

  • “table” - an unsigned 32 bit integer. The default depends on ipv4.route-table.

Therefore ipv4.routes " table=254" should do the trick.

What is the value of ipv4.route-table?
On my system:

$ nmcli -f ipv4.route-table c s bridge-brlan
ipv4.route-table:                       0 (unspec)

Oh, you have “100” there …

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.