How can I set the metric of a network interface (DHCP) permanently in Oracle Linux (think it is managed my NetworkManager)?
Asked
Active
Viewed 621 times
1 Answers
1
The network is managed by NetworkManager, you can use nmcli to set the metric:
to show connection use nmcli c (nmcli connection) , then use :
nmcli c edit CONNECTION_NAME
from the interactive mode to get the current metric use print:
nmcli> print
to set a metric:
nmcli> set ipv4.route-metric <value>
nmcli> set ipv6.route-metric <value>
nmcli> save
nmcli> quit
Or you can use the following command without running the interactive mode:
nmcli connection modify uuid UUID_CONNECTION ipv4.route-metric <value>
nmcli connection modify uuid UUID_CONNECTION ipv6.route-metric <value>
Then restart NetworkManager
sudo systemctl restart NetworkManager
to check it:
route -n
or
nmcli connection show uuid UUID_CONNECTION |grep route-metric
GAD3R
- 63,407
- 31
- 131
- 192
-
Would that be permanent after a reboot? – chris01 Feb 18 '21 at 11:12
-
@chris01 The NetworkManager should save the current configuration to be permanent. – GAD3R Feb 18 '21 at 11:52
-
1@chris01 All `nmcli connection modify` commands are permanent unless you explicitly add the `--temporary` option to make a non-permanent change. – telcoM Feb 18 '21 at 14:50
-
`systemctl restart NetworkManager` is almost always the wrong thing to do. NetworkManager will try *not* to apply any changes during restart, so the contrary of what the aim is here. Instead, after modifying a profile, make the changes effective by activating the profile (`nmcli connection up $NAME`). That is also the case, if the profile is currently already active, then just reactivate it (still with `nmcli con up`). – thaller Feb 21 '21 at 19:15