
Binding multiple addresses to a single Ethernet device
This recipe shows you how to bind multiple IP addresses to a single Ethernet device. The ability to assign more than one address to the same device can be useful-the most obvious benefit is that you don't need to procure multiple Ethernet cards. The cost of hardware has dropped substantially, but IT budgets still run tight. Perhaps a less obvious benefit, but one more valuable, is the greater flexibility it gives when configuring network services. Different services, such as e-mail and websites, can run on the same system but be accessed using different addresses.
Getting ready
This recipe requires a CentOS system with a working network connection. It assumes that your primary Ethernet device is enp0s3
and is configured with a static IP address. You'll also need administrative privileges provided by logging in with the root
account.
How to do it...
Follow these steps to bind multiple addresses to the same Ethernet device:
- Make a copy of the device's configuration file:
cp /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-enp0s3:1
- Open the new file with your text editor:
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3:1
- Delete the
UUID
entry entirely. If aHWADDR
entry exists, delete that also. - Update the
NAME
andDEVICE
values:NAME="System enp0s3:1" DEVICE="enp0s3:1"
- Change the value of
IPADDR
to the IP address you wish to use:IPADDR="192.168.56.101"
- Save your changes and close the file.
- Restart the networking service for the configuration changes to take effect:
systemctl restart network.service
How it works...
In this recipe, you learned how to assign multiple IP addresses to the same Ethernet device. We made a copy of one of the original network configuration files, taking care to name it appropriately to create a virtual adapter, and edited its configuration details. Since the name of the first device's configuration is ifcfg-enp0s3
, the new file is named ifcfg-enp0s3:1
to create the first virtual adapter associated with that device. If you want to add more adapters (assign more IP addresses), repeat the steps using incrementing numbers, for example, enp0s3:2
, enp0s3:3
, and so on.
In the configuration file, we removed the HWADDR
and UUID
entries since they are not needed for a virtual adapter. Then we updated the DEVICE
and NAME
entries to give the adapter its own identify, and, of course, we updated the IPADDR
entry to assign its IP address:

Multiple IP addresses are bound to an Ethernet device via a virtual adapter
See also
Refer to the following resources for more information on binding multiple addresses to the same Ethernet device:
- Create Multiple IP Addresses to One Single Network Interface (http://www.tecmint.com/create-multiple-ip-addresses-to-one-single-network-interface)
- Assign Multiple IP Addresses To Single Network Interface Card On CentOS 7 (http://www.unixmen.com/linux-basics-assign-multiple-ip-addresses-single-network-interface-card-centos-7)
- Adding Secondary IP Addresses (https://dbiers.me/adding-secondary-ip-addresses-centosrhel/)