You are not logged in.

#1 2017-01-06 12:54:23

leonshaw
Member
Registered: 2012-01-11
Posts: 19

Add static routes after DHCP with systemd-networkd

Hi,

I got two interfaces, each connected to a network with DHCP. I want to use enp0s3 as default route, but there is an internal subnet behind the gateway of enp0s8. My question is how to add route "10.0.100.0/24 via 192.168.100.1" with systemd-networkd?

The topology looks like:

          +-------------+                +----------+
          |   Network   |     Router     |          |
enp0s3 -- | 10.0.0.0/24 | -- 10.0.0.1 -- | Internet |
          |             |                |          |
          +-------------+                +----------+
                                            |
          +------------------+              |
          |     Network      |         Router
enp0s8 -- | 192.168.100.0/24 | ---- 192.168.100.1
          |                  |            |
          +------------------+            |
                                  +---------------+
                                  |               |
                                  | 10.0.100.0/24 |
                                  |               |
                                  +---------------+

10-enp0s3.network:

[Match]
Name=enp0s3

[Network]
DHCP=ipv4

20-enp0s8.network:

[Match]
Name=enp0s8

[Network]
DHCP=ipv4

[DHCP]
UseDNS=false
UseRoutes=false

[Route]
#Gateway=192.168.100.1
Destination=10.0.100.0/24

With the "Gateway" option, the route fails to add

Jan 06 20:28:20 arch systemd-networkd[938]: enp0s8: Could not set route: Network is unreachable

Seems DHCP is not finished yet. With "Gateway" commented-out, the route becomes:

10.0.100.0/24 dev enp0s8 proto static

which is not expected.

Offline

Board footer

Powered by FluxBB