When I tried to monitor my internet bandwidth with nethogs

$ sudo nethogs eth0

I got the following error:

ioctl failed while establishing local IP for selected device eth0. 
You may specify the device on the command line.

This is the output of sudo ip addr:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever

2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen1000 link/ether 20:6a:8a:5d:5d:1c brd ff:ff:ff:ff:ff:ff

3: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc pfifo_fast state UNKNOWNqlen 1000
    link/ether 56:10:e4:e0:61:f1 brd ff:ff:ff:ff:ff:ff
    inet brd scope global usb0
    inet6 fe80::5410:e4ff:fee0:61f1/64 scope link 
       valid_lft forever preferred_lft forever

4: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 20:7c:8f:79:88:ab brd ff:ff:ff:ff:ff:ff

Usually you get that answer when you try to monitor an interface which has no IP address assigned (probably not connected).

The output from ip addr shows that only one of your interfaces has an IP address, namely usb0.

So sudo nethogs usb0 should finally give the desired result.

As there are comments mentioning different interfaces: if ip addr shows several interfaces with IP-addresses assigned there are two options for you:

  • ip route show | grep default will show you the one device that is used to access "everything outside". e.g.
    default via dev eth1 proto static metric 100 tells me I have to use sudo nethogs eth1
  • If your goal is to look at internal traffic (within a local network or even between virtual machines on the same host) you can try with all devices found by ip addr or ip link.
  • 1
    Thanks. It was sudo nethogs eth1 for me. Apr 18 '15 at 6:53
  • In my case, in 64 bit ubuntu 15.05, usb0 is renamed as wlp6s0.
    – Anwar
    Nov 8 '15 at 17:08
  • check which interface holds the main IP using ifconfig and then use it with sudo nethogs <HERE>
    – AO_
    Apr 7 '16 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.