Skip to main content

What's the difference between a virtual network interface (e.g. eth0:1) and an alias or second [Resolved]

I apologize if the terminology I used in the title is incorrect, but I'm having a difficult time finding official terms/definitions. I'm on a CentOS 7 system and if I want to add a second IP address to an existing interface it seems I can either edit /etc/sysconfig/network-scripts/ifcfg-eth0 and add:

IPADDR1=xxx.xxx.xxx.xxx
PREFIX1=xx  

or I can create a new file containing the second IP (e.g. /etc/sysconfig/network-scripts/ifcfg-eth0:1).

What's the difference and when would I want to use one method over the other? I've already noticed that the ifconfig tool doesn't seem to find the IP when it's added as IPADDR1 under the same ifcfg file.

Thanks,


Question Credit: user
Question Reference
Asked September 21, 2019
Posted Under: Unix Linux
18 views
1 Answers

What's the difference and when would I want to use

eth0:1 is a sub-interface for example you can shutdown a sub-interface independently or tag traffic with a VLAN ID on a sub-interface.

ifconfig tool doesn't seem to find the IP when it's added as IPADDR1 under the same ifcfg file

You must use iproute 2 package instead of net-tools. You can find your second ip address with ip addr. ip route2 is the new package for networking userspace. `ifconfig is deprecated

net-tools utilities obsoleted by iproute2

$ ip addr
 1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
     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: enp1s0:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
     link/ether 52:54:00:8f:8c:86 brd ff:ff:ff:ff:ff:ff
     inet 192.168.122.197/24 brd 192.168.122.255 scope global dynamic noprefixroute enp1s0
        valid_lft 3546sec preferred_lft 3546sec
     inet 192.168.122.11/24 brd 192.168.122.255 scope global secondary noprefixroute enp1s0
        valid_lft forever preferred_lft forever
     inet6 fe80::4d61:1d19:14a4:a8dc/64 scope link noprefixroute 
        valid_lft forever preferred_lft forever

credit: Rasool Ziafaty
Answered September 21, 2019
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA