How to Set NIC priority on boot up

I have several Rocky boxes running on a Nutanix cluster with a private interface and a public interface. I want the public interface to come up first on a couple of the boxes but the private always comes up first. Is there a way to set a priority that makes the public NIC the primary NIC?

Why do you want a specific order? What does “primary NIC” mean to you?
What if the real solution to your issue is not in getting an interface up sooner or later?

I second what @jlehtone says, maybe explain exactly what your problem is and what you are trying to achieve. Is it because the default route is the private one and not the public one? If so, then you want to look at configuring the metric on the interface. For example like something here: How to set metric in OS moderated with NetworkManager - DEV Community although you will probably want a metric higher than 100, because that’s the default metric. So perhaps 20 or 50.

But ideally, it would be best to explain what you want to achieve so that we can provide a concise and correct solution to the problem.

The man nm-settings mentions “metric” for settings:


There are also various priority settings, including:


There are also ignore-auto-routes, ignore-auto-dns, and never-default for ipv4 and ipv6.

If one has many (similar) boxes, then maintaining their configuration with configuration management system, like Ansible, is worth the effort. There are even roles to configure the network.

1 Like

I appreciate any answers and advice that helps me resolve the issue I am facing.

Nutanix classifies ens3 (private NIC) as the primary NIC on all Linux boxes, not just Rocky. All Public interfaces are ens4 or something following. I need the public NIC to be what loads first because it is how I want to communicate to the box. I need the private NIC active because I do have scripts that reach out to this interface as well and I am not willing to change that. Nutanix labels the NIC based on the VLAN settings inside of the Nutanix cluster and the private VLAN number preceeds the public.

As of right, if the server reboots or the network service is restarted, I have to disable and enable the private NIC so that the public becomes the primary. I do have the private NIC behind the public in server configuration on the cluster and this is still happening.

Sorry, I still fail to understand why “loads first” would matter on how you communicate. Please explain.

What actually changes in your active network configuration when you do that? What is “primary”?

I don’t understand this. If I have two interfaces, private and public it shouldn’t matter which order they start, since I can access both. Unless, there is a routing table issue, or routing priority issue that is causing the connection problems from one of the interfaces. For example, if the private interface gateway is first, and the public interface gateway is second, then there can potentially be a routing problem in which case the routing tables need to be manipulated to say something along the lines of “if a packet was received on ens4, return it via the gateway for ens4”. That is possible to do.

If you want to change ordering of the interfaces, you would need to ask Nutanix to do that by connecting say ens3 to public, and ens4 to private. Similar to what I would do in a VM if I have two interfaces, and I install opnsense or some other firewall, that wants to configure the first assigned interface as internal, and second as external, and I wanted it for example the other way around I would just patch the interfaces differently. Something you cannot do, since you’d need to ask Nutanix to do the equivalent.

Either that, or I completely don’t understand the problem here.