The following config will help you to configure a virtual network interface to allow you to have multiple additional network IP address on a single hardware network interface. For example our RHEL server has currently a single hardware network interface called eth0. This interface is used as a master network interface with an IP address of 10.1.1.110. To this network interface we will attach two additional virtual network interfaces eth0:0 - 10.1.1.111 and eth0:1 - 10.1.1.112. Let's get started by showing a current network configuration:
[root@rhel7 ~]# ip addr show
Show network configuration on RHEL7 linux
From the above output we can see that currently we have configured eth0 network interface only. Next, we are going to locate a corresponding network interface configuration file for eth0:
# grep -l DEVICE.*eth0 /etc/sysconfig/network-scripts/*
Show network configuration file on RHEL7 linux
The configuration file responsible for the eth0 network interface is /etc/sysconfig/network-scripts/ifcfg-eth0
[root@rhel7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE="eth0"
NETBOOT="yes"
HWADDR="08:00:27:15:38:B7"
TYPE="Ethernet"
BOOTPROTO="none"
NAME="eth0"
UUID="462f4834-4fe7-43a7-84e7-83b2722e94c1"
ONBOOT="yes"
IPADDR="10.1.1.110"
NETMASK="255.0.0.0"
GATEWAY="10.1.1.1"
In order to create a virtual network interface we can first copy a master configuration file /etc/sysconfig/network-scripts/ifcfg-eth0 and then edit its content to set an appropriate network interface name and IP address:
[root@rhel7 ~]# cd /etc/sysconfig/network-scripts/
[root@rhel7 ~]# cp ifcfg-eth0 ifcfg-eth0:0
[root@rhel7 ~]# cp ifcfg-eth0 ifcfg-eth0:1
Next, we need to edit DEVICE, NAME, IPADDR in both virtual network configuration files. Below you can see both edited configuration files:

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


# cat /etc/sysconfig/network-scripts/ifcfg-eth0:0 
DEVICE="eth0:0"
NETBOOT="yes"
HWADDR="08:00:27:15:38:B7"
TYPE="Ethernet"
BOOTPROTO="none"
NAME="eth0:0"
UUID="462f4834-4fe7-43a7-84e7-83b2722e94c1"
ONBOOT="yes"
IPADDR="10.1.1.111"
NETMASK="255.0.0.0"
GATEWAY="10.1.1.1"
and
# cat /etc/sysconfig/network-scripts/ifcfg-eth0:1 
DEVICE="eth0:1"
NETBOOT="yes"
HWADDR="08:00:27:15:38:B7"
TYPE="Ethernet"
BOOTPROTO="none"
NAME="eth0:1"
UUID="462f4834-4fe7-43a7-84e7-83b2722e94c1"
ONBOOT="yes"
IPADDR="10.1.1.112"
NETMASK="255.0.0.0"
GATEWAY="10.1.1.1"
Once you have edited the additional virtual network interface files, all needs to be done is to restart your network. On RHEL7 linux server this can be achieved by:
[root@rhel7 ~]# systemctl restart network
Next, check your network settings again and look for two additional virtual network interfaces:
[root@rhel7 ~]# ip addr show
Show virtual network interfaces on RHEL7 linux
As a last and optional step you can test your newly configured virtual network interface with a ping command from some other host on your network:
Ping/Test virtual network interfaces on RHEL7 linux
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions