Ask Your Question
0

Proper Way To Hard Code Default Route with NM running

asked 2018-07-12 16:01:06 -0500

saltydog gravatar image

What is the proper way to hard code the default route on Fedora Core 28 Server running NetworkManager? I know I can turn it off, but that invariably causes systemd complaints. Were it just the one interface and basic routes it would be okay to let NM decide but it starts getting it wrong the second I add a route to an external network , changing the default route as in nmcli con del enp2s0 +ipv4.routes 192.168.203.0/24 ipv4.gateway 192.168.200.70 which resets the wanted default of 192.168.200.1 to *.70. Adding ipv4.never-default true will turn off DEFROUTE in the config file but it will also strip any GATEWAY designation which is not added except during nmcli con add ...

nmcli will create a route-ifname file for the route in NM syntax. As an alternate, it can take 'ip' syntax which it does if I add a file like:


192.168.203.0/24 via 192.168.200.70 dev enp2s0
default via 192.168.200.1 dev enp2s0

but when it comes up, it hasn't actually set a gateway route but a host route, so my guess it's just ignoring it.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-07-12 17:08:19 -0500

saltydog gravatar image

Well, as happens just after posting, I discovered a workaround was to add the additional routes via the NM dispatcher drop-in:

/etc/NetworkManager/dispatcher.d/02-add-routes


#!/bin/bash

[ "$2" != "up" ] && exit 0
[ "$1" != "enp2s0" ] && exit 0

/usr/sbin/ip route add 192.168.203.0/24 via 192.168.200.70

And then leave NM to set the default route on it's own. It's not exactly robust but it survives reboot

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-07-12 16:01:06 -0500

Seen: 19 times

Last updated: Jul 12