DEFROUTE vs GATEWAY in RHEL7
I've disabled Network Manager and I'm using ifcfg- scripts for network configuration. And I'm trying to find the difference between DEFROUTE="yes" and GATEWAY options.
I understand that "ifcfg files are parsed in numerically ascending order, and the last GATEWAY directive to be read is used to compose a default route in the routing table." as per RHEL documentation. But how is DEFROUTE used?
For instance ifcfg-em1 has DEFROUTE="yes" and the GATEWAY options specified. And ifcfg-em2 has only GATEWAY option. And I see that ifcfg-em2 GATEWAY is being added to the routing table as a default gateway. What is the reason to have DEFROUTE at all?
Thanks,
Best regards,
Roman
As per RHEL7 documentation:
In dynamic network environments, where mobile hosts are managed by NetworkManager, gateway information is likely to be interface specific and is best left to be assigned by DHCP. In special cases where it is necessary to influence NetworkManager's selection of the exit interface to be used to reach a gateway, make use of the DEFROUTE=no command in the ifcfg files for those interfaces which do not lead to the default gateway.
So DEFROUTE statement is only used by NetworkManager.
Assume that u have two network cards.
You have provided IP,subnet and gateway in both network card. Now system uses both cards to reach the destination.
When you put "DEFROUTE=yes" on one card then system always use card one on priority to reach every destination.