Due to some network peculiarities involving VPNs and conflicting IP ranges, I have two subnets routing to two different interfaces. I would like to make one IP address in one subnet go out via a different gateway.
I can accomplish this by running:
$ route add -host 1.2.3.4 gw 5.6.7.8
$ ip route show
1.2.3.4 via 5.6.7.8 dev eth0 scope link
I would like to make this change permanent. As I'm using systemd-networkd, I am trying to do this by updating the existing /etc/systemd/network/50-dhcp.conf
:
[Match]
Name=eth0
[Network]
DHCP=ipv4
[Route]
#Gateway=5.6.7.8
Destination=1.2.3.4/32
This works, but without the Gateway
line it doesn't set the route:
$ ip route show
1.2.3.4 dev eth0 proto static scope link
If I uncomment the Gateway
line then the new route does not appear at all!
How can I specify a gateway when adding the static route using systemd-networkd?
systemd
, and after rebooting it now works, regardless of order! So looks like this was a bug that has since been fixed. – Malvineous Apr 30 '19 at 08:29