How to Specify Default Device on Node with Multiple Interfaces

The Aerospike Knowledge Base has moved to https://support.aerospike.com. Content on https://discuss.aerospike.com is being migrated to either https://support.aerospike.com or https://docs.aerospike.com. Maintenance on articles stored in this repository ceased on December 31st 2022 and this article may be stale. If you have any questions, please do not hesitate to raise a case via https://support.aerospike.com.

Synopsis:

How to specify default gateway device if multiple interfaces are configured.

On Centos:

  • In order to set any specific device to be the default gateway device in the system, add following option in /etc/sysconfig/network: file: GATEWAYDEV=ethX

Note:

  • If a system has more than one interface, then the last interface which is being brought up will become the default gateway device. This is a designed behavior in RHEL initscripts.

On Ubuntu:

Modify metric value dynamically:

route add default dev eth0 metric 20

Increasing metric value of to say 20 will make it the least favorable interface to use by default.

Change can be made persistent by modifying /etc/network/interfaces

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
network xxx.xxx.xxx.xxx
broadcast xxx.xxx.xxx.xxx
metric XXX

a less friendly option is to modify default gateways

Point default gateway to interface:

ip route add -net 0.0.0.0/0 gw Gateway_IP dev eth0:1