2

Hie folks, I am trying to down particular IP from the set of up IP's, how to do this? For example lets consider I had up following IP's(sequence will be same): 1.2.3.4 1.2.3.5 1.2.3.6 I did this using "ifconfig etho:x 1.2.3.x up" where x=4,5,6. Now I want to down first IP alone i.e. 1.2.3.4, I am trying this as "ifconfig eth0:4 down". Problem is this not only downs required IP but also downs all the IP below it. I am working on Linux RedHat. Thanks in advance...

2 Answers2

2

ip addr del 1.2.3.4/24 dev eth0:4 The eth0:n aren't really interfaces, they are called labels(or aliases). Since you can assign multiple addresses to the same interface, labels can help differentiate what the ip is used for. That also explains why when you set a label down, everything else goes with it; since you are really just talking to eth0.

llua
  • 6,900
1

Most of the operating systems allow multiple IP addresses to be assigned to a single interface, this is called IP aliasing or logical network interface. We can associate multiple IP addresses with a particular label/alias. Alias are meant for our own convenience.

Here in the below case eth0:1 label is associated with 192.168.1.1 to 192.168.1.3 IP addresses. And eth0:2 label is associated with 192.168.1.4 to 192.168.1.6.

# ip addr add 192.168.1.1/24 dev eth0 label eth0:1
# ip addr add 192.168.1.2/24 dev eth0 label eth0:1
# ip addr add 192.168.1.3/24 dev eth0 label eth0:1
# ip addr add 192.168.1.4/24 dev eth0 label eth0:2
# ip addr add 192.168.1.5/24 dev eth0 label eth0:2
# ip addr add 192.168.1.6/24 dev eth0 label eth0:2

$ ip addr ls dev eth0 
    inet 192.168.1.1/24 scope global eth0:1
    inet 192.168.1.2/24 scope global secondary eth0:1
    inet 192.168.1.3/24 scope global secondary eth0:1
    inet 192.168.1.4/24 scope global secondary eth0:2
    inet 192.168.1.5/24 scope global secondary eth0:2
    inet 192.168.1.6/24 scope global secondary eth0:2

We can bring a particular IP addresses associated with an interface or multiple IP addresses associated with a alias.

Below command lists all IP addresses that are associated with eth0:1 label.

$ ip addr ls label eth0:1
    inet 192.168.1.1/24 scope global eth0:1
    inet 192.168.1.2/24 scope global secondary eth0:1
    inet 192.168.1.3/24 scope global secondary eth0:1

We can delete a particular IP address.

$ sudo ip addr del 192.168.1.3/24 dev eth0 
$ sudo ip addr ls label eth0:1
    inet 192.168.1.1/24 scope global eth0:1
    inet 192.168.1.2/24 scope global secondary eth0:1
Kannan Mohan
  • 3,231