0

In /lib/systemd/network/10-eth0.network on my client, I am failing to configure anything that can translate my manual command:

sudo ip route add default via 192.168.7.1 dev eth0 

where 192.168.7.1 is the static IPv4 address of my host.

My last 10-eth0.network configuration attempt:

[Match] Name=eth0 [Link] RequiredForOnline=no [Route] Address=192.168.7.2/24 Destination=192.168.7.1/32 Gateway=192.168.7.1 

Refreshed with sudo systemctl restart systemd-networkd and validated with ip route (it doesn't show up).

See also:

4
  • If 7.1 is the address of your host, 1) why are you specifying it as the gateway, and 2) what's 7.2 supposed to be then? Do you mean that 7.1 is the address of the router and 7.2 is the host with systemd? Commented Oct 24, 2024 at 5:12
  • 192.168.7.1 is arbitrary host Ethernet port to client's 192.168.7.2 Ethernet port. 192.168.7.1 is not a router per se. Router is in another subnet block, e.g. 10.0.0.1. Commented Oct 24, 2024 at 15:21
  • Okay, so .7.2 is the host being configured and .7.1 is another host. Is 192.168.7.1 acting as a router, at least? Commented Oct 24, 2024 at 16:36
  • 192.168.7.1 is an Ethernet interface of machine that is supposed to forward traffic via its WAN interface for the 192.168.7.2 'edge'/'client' device. Commented Oct 31, 2024 at 16:27

1 Answer 1

2

You didn't specify anywhere that it's supposed to be the default route; instead you have Destination=192.168.7.1/32 – which is the complete opposite of a default route... as well as being a cyclical (self-referencing) route. According to your configuration, it probably shows up as a 192.168.7.1/32 dev eth0 in your route output (that would be the effective interpretation assuming the kernel doesn't reject it).

The default route is always 0.0.0.0/0, i.e. a lowest-precedence catch-all route, and that's what you need to define as the Destination=. (Alternatively you can omit Destination= entirely.)

A route via Gateway=192.168.7.1 can only be defined if you are in the same subnet. For that, make sure that the Address=192.168.7.2 parameter is either in an [Address] section or in the [Network] section – it makes no sense in the [Route] section.

2
  • If it performs IP forwarding, it is a gateway by definition. Commented Nov 4, 2024 at 18:00
  • Adding Gateway=192.168.7.1 in the [Network] section works. Commented Nov 5, 2024 at 0:12

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.