Create Multiple IP Addresses to One Single Network Interface

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Narad Shrestha

He has over 10 years of rich IT experience which includes various Linux Distros, FOSS and Networking. Narad always believes sharing IT knowledge with others and adopts new technology with ease.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

63 Responses

  1. Gaurav says:

    If we add multiple IP to one NIC. Which IP will be shown if we ping using hostname?

    • Ravi Saive says:

      @Gaurav,

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

  2. Son says:

    can i setup those 3 ip to KVM ? I mean each KVM using each IP

  3. Anne says:

    Hello, Nice tutorial by the way. I have a question. I have configured two aliases on my NIC card eth0 (eth0:1 and eth0:2). However, I do not want them to be persistence.

    What I noticed though is that each time I make a change to the eth0:1 interface, the eth0:2 interface is deleted whereas the reverse is not true.

    Does it mean that changed to the lower other alias deletes the higher order i.e. ifconfig eth0:1 xxx.xxx.xx.xx delete eth0:2 ?

    Thanks so much for your kind assistance.

    • Ravi Saive says:

      @Anne,

      No that shouldn’t happen and each alias Network NIC is configured individually and work independently, this is something I really don’t’ understand, you need to check your configurations properly..

  4. dyh03 says:

    Hi,

    After I’m editing it using vi command for each ifcfg eth0:0 and eth0:1, then i want to check back if I’m inserting it correctly using command:

    # /etc/init.d/network restart
    

    then after that the output is “[failed]”

    then insert it “ifconfig” then it shows “command not found”, can i ask u guys, why this happens?

    • Ravi Saive says:

      @Haru,

      Please add the correct values to those ifcf interface files and about ifconfig command missing, you need to install it using yum package manager..

  5. ashwin says:

    when i try to make the files using ” cp ifcfg-eth0 ifcfg-eth0:0″
    it is showing me permission denied. pls help

    • Ravi Saive says:

      @Ashwin,

      I hope you running that command as root user, if not switch to root user and execute, it needs root privileges to execute that command.

  6. rajesh says:

    how many ips we can create using ip alisasing??

  7. dilip says:

    Please tell me how to add route permanently in linux

    • Ravi Saive says:

      @Dilip,

      To add a permanent static route on CentOS, RHEL or Fedora distributions, use the following command.

      # echo "192.168.10.0/16 via 192.168.5.5" >> /etc/sysconfig/network-scripts/route-eth0
      

      If you’re using Debian or Ubuntu distribution, try to run the following command to add a static route permanently.

      # echo "up route add -net 192.168.10.0/16 gw 192.168.5.5 dev eth0" >> /etc/network/interfaces
      

      Don’t forget to replace the IP address with your route IP address

  8. kashu says:

    typo…

    [root@ctos67 ~]# ip a s eth0
    2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:1c:9e:77 brd ff:ff:ff:ff:ff:ff
    inet 192.168.123.2/24 brd 192.168.123.255 scope global eth0
    inet6 fe80::5054:ff:fe1c:9e77/64 scope link
    valid_lft forever preferred_lft forever

    [root@ctos67 ~]# for i in {10..20}; do ip a a 192.168.123.${i}/24 dev eth0:$i; done
    [root@ctos67 ~]# ip a s eth0
    2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:1c:9e:77 brd ff:ff:ff:ff:ff:ff
    inet 192.168.123.2/24 brd 192.168.123.255 scope global eth0
    inet 192.168.123.10/24 scope global secondary eth0
    inet 192.168.123.11/24 scope global secondary eth0
    inet 192.168.123.12/24 scope global secondary eth0
    inet 192.168.123.13/24 scope global secondary eth0
    inet 192.168.123.14/24 scope global secondary eth0
    inet 192.168.123.15/24 scope global secondary eth0
    inet 192.168.123.16/24 scope global secondary eth0
    inet 192.168.123.17/24 scope global secondary eth0
    inet 192.168.123.18/24 scope global secondary eth0
    inet 192.168.123.19/24 scope global secondary eth0
    inet 192.168.123.20/24 scope global secondary eth0
    inet6 fe80::5054:ff:fe1c:9e77/64 scope link
    valid_lft forever preferred_lft forever

    [root@ctos67 ~]# for i in {10..20}; do ip a d 192.168.123.${i}/24 dev eth0:$i; done
    [root@ctos67 ~]# ip a s eth0
    2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:1c:9e:77 brd ff:ff:ff:ff:ff:ff
    inet 192.168.123.2/24 brd 192.168.123.255 scope global eth0
    inet6 fe80::5054:ff:fe1c:9e77/64 scope link
    valid_lft forever preferred_lft forever

  9. kashu says:

    I’d like to use ip command to temporarily create multiple ip address.

    for i in {0..10}; do ip a a 192.168.123.${i}/24 dev eth0:${i}; done

  10. akhil says:

    easy way is to use the command in centos
    ifconfig eth0:1 192.168.0.101

    • Bashed says:

      Set up a new Ubuntu 16 64bit Server. Need to bind the full /22 IPv4 as static. I can only ping .2 from the outside, but not the remainder and I’m stuck here.

      auto eno1
      iface eno1 inet static
      address xxx.xxx.16.2
      netmask 255.255.252.0
      network xxx.xxx.16.0
      broadcast xxx.xxx.19.255
      gateway xxx.xxx.16.1
      # dns-* options are implemented by the resolvconf package, if installed
      dns-nameservers 8.8.8.8 8.8.4.4
      dns-search domain.com

      This method won’t work

      root@server:~# ip addr add xxx.xxx.16.1/22 dev eno1
      root@server:~# ip addr show
      1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      inet 127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever
      inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
      2: eno1: mtu 1500 qdisc mq state UP group default qlen 1000
      link/ether d4:be:d9:ed:fb:8a brd ff:ff:ff:ff:ff:ff
      inet xxx.xxx.16.2/22 brd xxx.xxx.19.255 scope global eno1
      valid_lft forever preferred_lft forever
      inet xxx.xxx.16.1/22 scope global secondary eno1
      valid_lft forever preferred_lft forever
      inet6 fe80::d6be:d9ff:feed:fb8a/64 scope link
      valid_lft forever preferred_lft forever
      3: eno2: mtu 1500 qdisc noop state DOWN group default qlen 1000
      link/ether d4:be:d9:ed:fb:8c brd ff:ff:ff:ff:ff:ff
      4: eno3: mtu 1500 qdisc noop state DOWN group default qlen 1000
      link/ether d4:be:d9:ed:fb:8e brd ff:ff:ff:ff:ff:ff
      5: eno4: mtu 1500 qdisc noop state DOWN group default qlen 1000
      link/ether d4:be:d9:ed:fb:90 brd ff:ff:ff:ff:ff:ff

      root@server:~# ifconfig
      eno1: flags=4163 mtu 1500
      inet xxx.xxx.16.2 netmask 255.255.252.0 broadcast xxx.xxx.19.255
      inet6 fe80::d6be:d9ff:feed:fb8a prefixlen 64 scopeid 0x20
      ether d4:be:d9:ed:fb:8a txqueuelen 1000 (Ethernet)
      RX packets 28742 bytes 1879979 (1.8 MB)
      RX errors 0 dropped 0 overruns 0 frame 0
      TX packets 989 bytes 112470 (112.4 KB)
      TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

      root@server:~# echo “up route add -net xxx.xxx.16.0/22 gw xxx.xxx.16.1 dev eno1” >> /etc/network/interfaces
      root@server:~# nano /etc/network/interfaces

      All it did was add this line in interfaces file

      up route add -net xxx.xxx.16.0/22 gw xxx.xxx.16.1 dev eno1

Got something to say? Join the discussion.

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

Join Over 300K+ Linux Users
  1. 177,942
  2. 8,310
  3. 37,548

Are you subscribed?