Linux – How to get rid of veth interfaces

linuxnetworkingUbuntuvirtual-network

I am not sure why / when, some veth interfaces have appeared in my system (Ubuntu 16.0. LTS):

ยป ifconfig | grep veth
veth4556676 Link encap:Ethernet  HWaddr ee:b9:b9:ed:71:a6  
veth8747335 Link encap:Ethernet  HWaddr 66:40:47:fd:1f:a7  
veth13905bf Link encap:Ethernet  HWaddr ae:73:8f:f7:9d:d4  
veth2636dd7 Link encap:Ethernet  HWaddr fa:b8:3c:d4:52:9c  
veth42de626 Link encap:Ethernet  HWaddr 92:08:43:90:6e:f3  
veth4eedb05 Link encap:Ethernet  HWaddr 66:5f:b8:e7:52:05  
veth7534db0 Link encap:Ethernet  HWaddr 16:9c:06:e6:f2:aa  
veth83508c7 Link encap:Ethernet  HWaddr 5a:55:6c:ee:e5:7b  
veth8f275d6 Link encap:Ethernet  HWaddr 46:18:a1:52:7f:e9  
veth9f370c9 Link encap:Ethernet  HWaddr da:9e:49:37:b4:16  
vethb96da94 Link encap:Ethernet  HWaddr 42:11:90:11:8a:f4  
vethba463c9 Link encap:Ethernet  HWaddr 06:40:d5:9a:79:7a  
vethd820900 Link encap:Ethernet  HWaddr a2:94:53:c8:53:bf  
vethdd077a0 Link encap:Ethernet  HWaddr 1a:f9:00:93:05:5e  
vethef191e6 Link encap:Ethernet  HWaddr b2:b0:e1:68:50:7c  
vethf70a6f9 Link encap:Ethernet  HWaddr a6:a7:72:dd:88:69  

This happens in a freshly rebooted system. I have two questions:

  1. Why are those veth interfaces present?
  2. How can I get rid of them?

Note: I have lately been doing some Vagrant / VirtualBox related stuff, so that could be the reason.

Best Answer

Why are those veth interfaces present ?

Possibly because you are using a Virtualization Platform such as vmware or virtualbox or vagrant.

Getting rid of veth interfaces !

I suppose a better solution exists, but for the time being you can do it this way.

  • Getting the name of interfaces

    ifconfig | grep "^veth" | cut -d' ' -f1
    

    Here grep "^veth" selects only those interfaces (listed by ifconfig) that start with veth and cut shows only the names by delimiting the contents and showing only first field.

  • Now we have to shut down the drivers for these interface using

    ifconfig vethxxxxxx down
    

    Also, you can do it by using ip command ( as suggested by @dirkt in comments ).

    ip link set $veth down
    

    But since there are too many of them, use for loop like this :

    for veth in $(ifconfig | grep "^veth" | cut -d' ' -f1)
    do
        ifconfig $veth down    # OR this ip link set $veth down
    done
    
  • Here's one-liner for copy paste :

    for veth in $(ifconfig | grep "^veth" | cut -d' ' -f1); do ifconfig $veth down; done
    

Feel free to add in more stuff to the answer.

Related Question