In AlmaLinux 9 NetworkManager should be used to define connections. In the datacenter we use a route has to be defined in order to use custom IP from virtual machine. I have made progress defining IPs in host, but couldn't manage to have NetworkManager creating the route upon restart, but with this command network is working:
ip route add default via 192.168.0.1 dev ens18 onlink src 94.23.81.XXX
I'm not familiar with nmconnection file format so I couldn't make it with NetworkManager. Where should I put this command or in which file could I define this default and only route?
Thanks.
This documentation contains a variety of examples of how to use
nmcli
to create static routes. It doesn't cover the use of custom attributes likeonlink
, but we can find that in thenmcli
documentation, which tells us that the value of theipv4.routes
option is:Suggesting that we can do this (assuming that we have a connection named
wired
, which I do):Which, when I run it on my system, results in:
Note that you will need to
nmcli down
/nmcli up
the connection for the changes to be realized.