Linux CentOS multiple default gateway for Virtual NIC interface

If your server needs to have multiple IP addresses on the same physical NIC, you need to create multiple Virtual Interfaces. For example, the default eth0 configuration will have an IP address from one network IP block, but you need to add another IP address, from a different IP block, with a different gateway.
Here are the steps to add multiple IP addresses with multiple default gateways on the same physical NIC:

Create a separate file in /etc/sysconfig/network-scripts called eth0:1 or eth0:2, etc.  Increment for each new IP address. File location may be different depending on your OS version and environment. This path works for CentOS 5.5.

Paste the following information into the file; use your own MAC address, IP address and gateway information:

BOOTPROTO=none
NAME=""
GATEWAY=12.34.45.67
MACADDR=""
DEVICE=eth0:1
NETMASK=255.255.255.0
MTU=""
BROADCAST=12.34.45.255
ONPARENT=yes
IPADDR=12.34.45.68
NETWORK=12.34.45.0
ONBOOT=yes

Save the file, and apply the new network config.

Leave a Reply

Your email address will not be published. Required fields are marked *