• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to create Multiple IP Address to Single Network interface

499

To create Multiple IP Address to Single Network interface

Creating multiple IP address using a single network interface is known as IP aliasing. Aliasing does not require any additional adaptors.This makes aliasing more cost effect. Procedure to create Multiple IP Address to a single interface is explained in this article.


To Assigning multiple IP’ s on a single network interface

Navigate to the path where the network configuration files are placed by utilising the following command.

[root@linuxhelp ~]# cd /etc/sysconfig/network-scripts/
[root@linuxhelp network-scripts]# ll
total 224
-rw-r--r--  5 root root   256 Jul 15 18:25 ifcfg-eth0
-rw-r--r--  1 root root   254 Apr  9  2015 ifcfg-lo
lrwxrwxrwx  1 root root    20 Mar 30 18:43 ifdown ->  ../../../sbin/ifdown
-rwxr-xr-x  1 root root   627 Apr  9  2015 ifdown-bnep
.
.
.
-rwxr-xr-x  1 root root  1219 Apr  9  2015 net.hotplug
-rw-r--r--  1 root root 14644 Apr  9  2015 network-functions
-rw-r--r--  1 root root 29853 Apr  9  2015 network-functions-ipv6

Check the physical adapter' s IP address through ip command.

[root@linuxhelp network-scripts]# ip a

1: lo: < LOOPBACK,UP,LOWER_UP>  mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: < BROADCAST,MULTICAST,UP,LOWER_UP>  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:3f:43:a5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.5.182/24 brd 192.168.5.255 scope global eth0
    inet6 fe80::20c:29ff:fe3f:43a5/64 scope link
       valid_lft forever preferred_lft forever

Here the physical eth0 interface IP is “ 192.168.5.182” .
Lets create three virtual network interface(aliases) for eth0 as eth0:0 , eth0:1 , eth0:2 with the IP address 192.168.5.184 , 192.168.5.185 , 192.168.5.186 respectively.

[root@linuxhelp network-scripts]# cp ifcfg-eth0 ifcfg-eth0:0
[root@linuxhelp network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1
[root@linuxhelp network-scripts]# cp ifcfg-eth0 ifcfg-eth0:2

Open the ifcfg-eth0:0 file and edit as follows.

[root@linuxhelp network-scripts]# vim ifcfg-eth0:0
DEVICE=eth0:0
HWADDR=00:0C:29:3F:43:A5
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.5.184
NETMASK=255.255.255.0
GATEWAY=192.168.5.1
DNS=8.8.8.8

Then open ifcfg-eth0:1 file and alter it as follows

[root@linuxhelp network-scripts]# vim ifcfg-eth0:1
DEVICE=eth0:1
HWADDR=00:0C:29:3F:43:A5
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.5.185
NETMASK=255.255.255.0
GATEWAY=192.168.5.1
DNS=8.8.8.8

Unfold the ifcfg-eth0:2 config file and edit it as follows.

[root@linuxhelp network-scripts]# vim ifcfg-eth0:2
DEVICE=eth0:2
HWADDR=00:0C:29:3F:43:A5
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.5.186
NETMASK=255.255.255.0
GATEWAY=192.168.5.1
DNS=8.8.8.8

Restart the network service.

[root@linuxhelp network-scripts]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Determining if ip address 192.168.5.182 is already in use for device eth0...
Determining if ip address 192.168.5.184 is already in use for device eth0...
Determining if ip address 192.168.5.185 is already in use for device eth0...
Determining if ip address 192.168.5.186 is already in use for device eth0...
                                                           [  OK  ]

Again check the physical adapter' s IP address using ip command.

[root@linuxhelp network-scripts]# ip a
1: lo: < LOOPBACK,UP,LOWER_UP>  mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: < BROADCAST,MULTICAST,UP,LOWER_UP>  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:3f:43:a5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.5.182/24 brd 192.168.5.255 scope global eth0
    inet 192.168.5.184/24 brd 192.168.5.255 scope global secondary eth0:0
    inet 192.168.5.185/24 brd 192.168.5.255 scope global secondary eth0:1
    inet 192.168.5.186/24 brd 192.168.5.255 scope global secondary eth0:2
    inet6 fe80::20c:29ff:fe3f:43a5/64 scope link
       valid_lft forever preferred_lft forever

Now you can check the IP’ s by pinging from other machines.


To Assign set of IP range on a single network interface

Copy and rename the physical network interface as " ifcfg-eth0-range0”

[root@linuxhelp network-scripts]# cp -p ifcfg-eth0 ifcfg-eth0-range0

Open the ifcfg-eth0-range0 file and edit as below

[root@linuxhelp network-scripts]# vim ifcfg-eth0-range0
DEVICE=eth0
HWADDR=00:0C:29:3F:43:A5
TYPE=Ethernet
UUID=9aba66e1-41ab-4f3f-8f29-5a9c188f19ab
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR_START=192.168.5.184
IPADDR_END=192.168.5.186
NETMASK=255.255.255.0
DNS2=8.8.4.4
GATEWAY=192.168.5.1
DNS1=8.8.8.8
IPV6INIT=no
USERCTL=no

Restart the network service by using the following command.

[root@linuxhelp network-scripts]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Determining if ip address 192.168.5.182 is already in use for device eth0...
Determining if ip address 192.168.5.184 is already in use for device eth0...
Determining if ip address 192.168.5.185 is already in use for device eth0...
Determining if ip address 192.168.5.186 is already in use for device eth0...
                                                           [  OK  ]

Then check the physical adapter' s IP address through ip command.

[root@linuxhelp network-scripts]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0C:29:3F:43:A5  
          inet addr:192.168.5.182  Bcast:192.168.5.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe3f:43a5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9377 errors:0 dropped:0 overruns:0 frame:0
          TX packets:842 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:827629 (808.2 KiB)  TX bytes:58456 (57.0 KiB)

eth0:     Link encap:Ethernet  HWaddr 00:0C:29:3F:43:A5  
          inet addr:192.168.5.184  Bcast:192.168.5.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:3F:43:A5  
          inet addr:192.168.5.185  Bcast:192.168.5.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth0:2    Link encap:Ethernet  HWaddr 00:0C:29:3F:43:A5  
          inet addr:192.168.5.186  Bcast:192.168.5.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:960 (960.0 b)  TX bytes:960 (960.0 b)

Save

Tags:
gabriel
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

while performing this option "cp ifcfg-eth0 ifcfg-eth0:0" it shows permission denied

A

This needs to be executed as root user

Q

Is IP/Network configuration be managed under nmcli and nmtui?

A

yes in Centos7/RHEL 7 you can manage IP/Network configuration via nmcli and nmtui

Q

How to enable network interface via command line?

A

use following command
#ifup "interface name" (or)
# nmcli connection up "interface name"

Q

Where I can manually set network configuration in Debian based os?

A

The network configuration is located Under "/etc/network/interfaces"

Q

What is the purpose of creating multiple ip?

A

Assigning multiple IP addresses means creating multiple NIC’s using one single Network interface with each different name and different IP.

Related Tutorials in How to create Multiple IP Address to Single Network interface

Related Tutorials in How to create Multiple IP Address to Single Network interface

IP Commands to Configure Network Interfaces
IP Commands to Configure Network Interfaces
Apr 8, 2016
How to create Multiple IP Address to Single Network interface
How to create Multiple IP Address to Single Network interface
Jul 21, 2016
Difference between ip and ifconfig command
Difference between ip and ifconfig command
Jun 1, 2016

Related Forums in How to create Multiple IP Address to Single Network interface

Related Forums in How to create Multiple IP Address to Single Network interface

ip command
oliver class=
How to view the outside IP from command-line in linux
May 15, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ryan ?
how to use visual traceroute tool

Am using traceroute command to check for the route. i got this tool while surfing. So pls help me out installation and usage of Visual traceroute tool.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.