[systemd-devel] Policy-based routing setup

Thomas Köller thomas at koeller.dyndns.org
Wed Feb 1 00:23:12 UTC 2023


I have the following lines im a .network file:

[RoutingPolicyRule]
Priority = 10
IncomingInterface = lo
OutgoingInterface = bo_lan
DestinationPort = 22
IPProtocol = tcp
Family = both
InvertRule = yes
Table = 100

[Route]
Gateway = 192.168.0.1
GatewayOnLink = yes
Destination = 0.0.0.0/0
Scope = link
Protocol = static
Table = 100

[Route]
Gateway = fd46:1ffa:d8e0::1
GatewayOnLink = yes
Destination = ::/0
Scope = link
IPv6Preference = medium
Protocol = static
Table = 100


After the interface is started, the rule is indeed set up as expected:

[root at raspi-400 network]# ip rule
0:    from all lookup local
10:    not from all iif lo oif bo_lan ipproto tcp dport 22 lookup sshvpn 
proto static
32766:    from all lookup main
32767:    from all lookup default


The routes, however, are not:

[root at raspi-400 network]# ip route show table 100
[root at raspi-400 network]# ip -6 route show table 100
[root at raspi-400 network]#


The commands above do not return an error, unlike the case when a 
different table number is used:

[root at raspi-400 network]# ip route show table 101
Error: ipv4: FIB table does not exist.
Dump terminated
[root at raspi-400 network]#


This seems to indicate that the routing table has in fact been set up, 
but to an empty state. Am I doing something wrong here?




More information about the systemd-devel mailing list