I have a question regarding RedHat 6 Enterprise Network Manager (NM):

My Linux is connected to two network interfaces.

1 – eth0: Normal Ethernet which is connected to the company LAN

2 – eth1: An USB dongle which is connected to a cellular network (CDC-ECM)

eth0 interface is always connected and eth1 interface is non-permanent (the connection can come and go)

When both connected, NM gives priority to eth0. Meaning, the default route ( is always defined through it.

I want to change the NM policy that it will give higher priority to eth1. When the eth1 interface is not connected the default route should defined through eth0 interface and when eth1 is connected the default route should go through eth1.

I searched the net on how to do it and played with the NM scripts and ifcfg-eth0 / ifcfg-eth1 files (tried DEFROUTE and other options) but couldn’t make it work.

Can anyone suggest what should be the right way to do it using NM ?

Thanks !


Edit: Add OP's solution from comments:

  • Remove eth0 (wired) from NM
  • Left eth1 (wireless) controlled.
    • The default when NM_CONTROLLED is omitted
  • Set eth1 METRIC=20
  • Produces 2 default routes where eth1 takes precedence


Network Manager may always choose wireless or wired as primary (based on other questions here) which seems to include interactions with the route's metric and dhcp, router advertisements (where NM followed a 1 metric), interface up/down and RedHat-specifics.

Assuming you're using it: DHCP may reset your route to the "better" one according to its route metric¹. Higher metric values are more "expensive" so the less costly metrics are preferred. In the Network Manager list here, it's noted that dhcp wireless metrics are penalized +100, and the NM developers say NM should just choose the right route, but also that metrics may be the best device method. I'm not sure this applies to your eth1, but you can control it:

Swapping the numbers (10 and 20) from this answer for your interfaces, I get:

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth1

That answer says this should prefer wireless and perform a graceful failover between interfaces.

If you want NM to select as the dev's may intend, GMambaG's interface keywords are also considered in the RedHat docs for static routes, which note unexpected problems using multiple gateways + GATEWAYDEV. To test that, start both interfaces and try to resume operations after removing eth1. If you have trouble (like intermittent timeouts), you should be able to recover by removing your changes and restarting networking:

$ sudo service network restart

If all else fails, router advertisements (ICMP types 9 and 10 I think) may be affecting your route tables; coordinate with the network admin before trying to block them.

Edit: Reduced this answer's text, placed OP's solution on top.

¹ If you're not using DHCP you'd have a manual gateway. This article suggests using NM_CONTROLLED="no" to prevent NM from automatically switching to that interface's gateway.

  • Thanks you very much for your detailed answer ! unfortunately I tried this and still eth0 takes priority. the metric and the GATEWAYDEV doesn't seems to effect NM. In the logs I see "Policy set 'eth0' (eth0) as default for IPv4 routing and DNS." any idea what is wrong ? – Kimel Apr 15 '15 at 11:40
  • bugzilla.gnome.org/show_bug.cgi?id=653789 (not a bug) says to select "Use this connection only for resources on its own network" within NM, the interface, IPv4 settings, routes . If what it means looks right for you (the comments are short) I'll add it and the source to the answer. – ǝɲǝɲbρɯͽ Apr 15 '15 at 13:55
  • Thanks again, well it is not exactly what I need. if I choose "Use the connection only for resources on it network", there will be no default route on that interface. I need a default route on eth0 when eth1 is unplugged. – Kimel Apr 15 '15 at 14:21
  • Of course; thanks for the reminder. I have a similar config but can't test failover; in this answer: serverfault.com/a/417404/246220 it is implied that you can swap the gateway interface at that point, using commands like the route changes made here: stackoverflow.com/a/10907667/3981745 . Someone may chime in with a better solution but I can add it anyway. – ǝɲǝɲbρɯͽ Apr 15 '15 at 14:51
  • Eventually what I did is to remove eth0 from NM NM_CONTROLLED=no and left eth1 controlled. for the eth0 I set the metric to 20 and then I have 2 default routes and the eth1 takes precedence. currently this looks fine for me. Thanks again for your help and effort , I appreciate it very much ! – Kimel Apr 15 '15 at 16:39

Red Hat uses the last interface up as the default gateway device.

To set eth1 as the default, add this to /etc/sysconfig/network:


See: https://access.redhat.com/solutions/41459

It should get processed on every ifup call. You can check the routes with ip route show

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.