Linux command to remove virtual interfaces or network aliases

See all GNU/Linux related FAQ
How do I remove virtual interfaces such as eth0:1 or eth1:1?

Use the ifconfig command or ip command to remove virtual interfaces or network aliases under Linux operating systems. The ip or deprecated ifconfig command is used to configure the kernel-resident network interfaces. It is used at Linux boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed. Please note that network IP Aliases are not real network devices, but programs should be able to configure and refer to them, as usual, using the ifconfig, ip, and route commands. These are used to assign multiple ip addresses to a single network interface on your Linux machine. So, for example, I can have five usable public IPv4 assigned to the eth0 interface to host five different web apps, each with a unique IPv4 address. Let us see how to remove virtual interfaces or network aliases under Linux.
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux terminal
Category Network Utilities
OS compatibility AlmaLinux Alpine Arch Debian Fedora Linux Mint openSUSE Pop!_OS RHEL Rocky Stream SUSE Ubuntu
Est. reading time 3 minutes

Listing Linux interfaces

Type any one of the following command to get a list of NICs (network interface cards) on Linux:
# ip link show
# get info about eth0 or enp0s31f6 NIC #
# ip addr show enp0s31f6

Here is what you may see:

2: enp0s31f6:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 48:2a:e3:5c:16:bc brd ff:ff:ff:ff:ff:ff
    inet brd scope global dynamic noprefixroute enp0s31f6
       valid_lft 6354sec preferred_lft 6354sec
    inet scope global secondary enp0s31f6
       valid_lft forever preferred_lft forever
    inet brd scope global secondary enp0s31f6:0
       valid_lft forever preferred_lft forever
    inet6 fe80::4a2a:e3ff:fe5c:16bc/64 scope link 
       valid_lft forever preferred_lft forever

Please note that the global secondary line indicates virtual interfaces such as enp0s31f6:0 and their IP address. You can also use the ifconfig command on an older Linux system:
# ifconfig -a
# filter out results using the grep command #
# ifconfig -a | grep -A 6 eth0


eth0: flags=4163  mtu 1500
        inet  netmask  broadcast
        inet6 fe80::4a2a:e3ff:fe5c:16bc  prefixlen 64  scopeid 0x20
        ether 48:2a:e3:5c:16:bc  txqueuelen 1000  (Ethernet)
        RX packets 23858  bytes 21803276 (21.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 17321  bytes 7183523 (7.1 MB)
eth0:1: flags=4163  mtu 1500
        inet  netmask  broadcast
        ether 48:2a:e3:5c:16:bc  txqueuelen 1000  (Ethernet)
        device interrupt 16  memory 0xee500000-ee520000  

Again, note that the eth0:1: line indicates virtual interfaces and IP addresses such as

Linux command to remove virtual interfaces or network aliases

Open the terminal application. Type the following command to remove eth0:1 alias using the ifconfig command:
# ifconfig eth0:1 down
# ifconfig -a
# ifconfig -a | grep -A 6 eth0

Another option on modern Linux distro is the ip command as follows to deletes the network alias by its IP address such as as
# ip address del dev eth0

/etc/sysconfig/network-scripts/ifcfg-ethX-range0 file

To remove interface permanently edit network configuration file stored at /etc/directory. For Red Hat / Fedora Core file stored in /etc/sysconfig/network-scripts/ directory. For Debian or Ubuntu Linux just edit file /etc/network/interfaces and remove the entries. For example open file called /etc/sysconfig/network-scripts/ifcfg-eth1-range0 file using a text editor such as vi/vim or nano:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0-range0
You will see network aliases configuration:

Just comment out everything or just rename the file using the mv command:
# mv /etc/sysconfig/network-scripts/ifcfg-eth0-range0 /etc/sysconfig/network-scripts/working.ifcfg-eth0-range0.backup
Finally, restart Linux network service:
# service network restart
OR use the systemctl command on modern Linux distro:
# systemctl restart network

A note about removing virtual interfaces in Linux

Summing up

Typically we add the IP address to the eth0 network interface as eth0:1:
# ifconfig eth0:1 up
And then delete when work is done:
# ifconfig eth0:1 down
However, with modern Linux distro we use the ip command. To add:
# ip address add dev eth0
To delete:
# ip address del dev eth0
The config file for aliases on a RHEL and co located in the /etc/sysconfig/network-scripts/ifup-aliases or /etc/sysconfig/network-scripts/ifcfg-eth1-range0. For Debian/Ubuntu Linux look into /etc/network/interfaces file. Also read the following manual pages using the man command or help command:
$ man ip
$ man ifconfig

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

8 comments… add one
  • Ravi Feb 10, 2010 @ 12:34

    Thanks Vivek, Very informative article, I hope its easy to use virtual interface, can you suggest how do I disable the alias/virtual interfaces at boot time and up this after system boot when I want manully, or through /etc/init.d/network cmd, I have already found this range file option but did not get the range break, like IPADDR_START= to
    IPADDR_END= but not start the IP how its possible


  • Jim Jun 29, 2011 @ 23:17

    Little late with this but what the hey. You must be careful using ifconfig ethx:x down. If you run more than one virtual interface on a network card taking one out of the middle will move the list up. Say if you have 4 virtual interfaces of which the first is the real eth1. So if you take out eth1:2 then eth1:3 becomes eth1:2 and eth1:4 becomes eth1:3. This may confuse some scripts that deal with virtual interfaces. Beware.

  • James Cordell Mar 2, 2012 @ 10:11

    I find this does not work for me. I am trying to remove a virtual interface

    bond0:514 Link encap:Ethernet HWaddr 00:1F:F4:F6:DF:36
    inet addr: Bcast: Mask:

    # ifconfig bond0:154 down
    SIOCSIFFLAGS: Cannot assign requested address

    im on.
    Linux 2.6.18-92.1.22.el5 #1 SMP Tue Dec 16 11:57:43 EST 2008 x86_64 x86_64 x86_64 GNU/Linux

  • sidharth Apr 4, 2012 @ 4:46

    I have some 3 nic cards on my system. I have removed all from /etc/sysconfig/network-scripts and want to assign a single ip to the system. But still in setup I can see 3 devices present. Please help..

    Thanks in advance

  • rollnthnder Dec 17, 2014 @ 21:15

    removing a sub-interface.
    when i remove the file /etc/sysconfig/network-scripts/ifcfg-eth1:0
    my system is hosed every time.
    what’s up with that?
    i can change the ip inside eth1:0 to and the command ip addr verifies that the eth1:0
    is gone. but removing the config file, ifcfg-eth1:0 kills my eth1 connection.

  • Lionel Jul 31, 2022 @ 15:30

    I was looking for a way to permanently remove a network interface and you gave me the solution.
    Thanks a lot.

  • Ulrich Sep 1, 2023 @ 7:25

    systemctl restart netwrok

    should be

    systemctl restart network

    • 🛡️ Vivek Gite (Author and Admin) Vivek Gite Sep 1, 2023 @ 10:51

      Fixed it. Thanks for the heads up!

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.