5

I am running kali linux on a virtual machine (VM). I started the machine today and noticed that the interface eth0 is missing.

So I tried ifup eth0 to start it, but got output: unknown interface eth0.

But if I execute ethtool eth0 then I get this output:

Settings for eth0:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Supported FEC modes: Not reported
    Advertised link modes:  10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Advertised FEC modes: Not reported
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: Unknown (auto)
    Supports Wake-on: d
    Wake-on: d
    Current message level: 0x00000007 (7)
                   drv probe link
    Link detected: no

2 Answers 2

10

The reason of this error is that here, eth0 means two different things:

  • either the actual interface name, as seen by the kernel, iproute2 tools, ethtool, dhclient, etc. which does exist,

  • or the interface configuration in the ifupdown tools, pointing to the actual interface name. Here, if eth0 was never defined in the configuration, then it's not known by ifup: that's the error message.

    An easy way to reproduce this error:

    # ip link add name veth5 type veth peer name veth6
    # ethtool veth5
    Settings for veth5:
        Supported ports: [ ]
    [...]
        Link detected: no
    # ifup veth5
    ifup: unknown interface veth5
    

So the interface is not missing. the ifupdown tool has not been configured to use it.

For your case, you could add at the end of /etc/network/interfaces (or in a separate file for example /etc/network/interfaces.d/eth0 if the interfaces file includes the interfaces.d directory in its config) these two lines:

auto eth0
iface eth0 inet dhcp

To have the ifupdown tools and so the ifup command know about it and configure it with DHCP at boot. I have no idea why this wasn't in place before.

In my previous fake example where I added likewise veth5's definition (on Debian 9):

# ifup -a
Internet Systems Consortium DHCP Client 4.3.5
Copyright 2004-2016 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/veth5/1e:96:59:c3:e4:0c
Sending on   LPF/veth5/1e:96:59:c3:e4:0c
Sending on   Socket/fallback
DHCPDISCOVER on veth5 to 255.255.255.255 port 67 interval 8
6
  • I added a file named eth0 under /etc/network/interfaces.d/ folder and I configured it as static IP address. I restarted networking service but sudo ifup eth0 again give the same error. Why? ethtool shows that eth0 exists.
    – user458762
    Commented Feb 18, 2022 at 14:22
  • @hophop Use ifup -v eth0 and ifdown -v eth0: debug information will tell you where it fails. Usually it's when there's a discrepancy between the real state and the ifupdown state: eg trying to add an address on an interface where the address was already added => error.
    – A.B
    Commented Feb 18, 2022 at 15:34
  • @hophop this could also be because the condition I wrote in the answer is not met: " if the interfaces file includes the interfaces.d directory in its config". If you still can't find, this will have to be in a new Q/A.
    – A.B
    Commented Feb 18, 2022 at 16:20
  • Actually I did create my own file under /etc/network/interfaces.d/ named as eth0 and configure it with dhcp, gateway etc. However, it does not work and gives the same error too. Therefore, I am opening a new question soon about that topic. Thanks.
    – user458762
    Commented Feb 18, 2022 at 16:36
  • 1
    I did your advice and dumped and reorganize all interfaces and this time used allow-hotplug option for interfaces(since I am using USB modem) and everyting seem ok now.
    – user458762
    Commented Feb 18, 2022 at 17:41
4

I solved it by executing the command dhclient

dhclient - Dynamic Host Configuration Protocol Client

The Internet Systems Consortium DHCP Client, dhclient, provides a means for configuring one or more network interfaces using the Dynamic Host Configuration Protocol, BOOTP protocol, or if these protocols fail, by statically assigning an address.

...

The names of the network interfaces that dhclient should attempt to configure may be specified on the command line. If no interface names are specified on the command line dhclient will normally identify all network interfaces, eliminating non-broadcast interfaces if possible, and attempt to configure each interface.

3
  • Thanks! Can you provide an example of the command arguments you ran?
    – idolize
    Commented May 26, 2020 at 20:35
  • @idolize, sorry, too long ago. Can't remember if I used any arguments.
    – Black
    Commented Jun 17, 2020 at 13:23
  • sudo dhclient -v eth0 will bring the ethernet up and get an IP address - sharing for the next person trying to figure out why ubuntu server won't bring up the network on fresh install / boot.
    – bsautner
    Commented Aug 16, 2023 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .