Ubuntu – Hostname -I spamming more than one IP address

command linenetworking

Sometimes I run

hostname -I

on my machine and got only one local IP returned like 192.168.0.10, but lately, there is occasions where I type it and got in return both 192.168.0.10 192.168.122.1.

If I go to my router page and to traffic settings, I don't see this second IP connected to it. How can I go further to investigate what is exactly this other IP, if its related to some other program or even to a security problem?

Best Answer

hostname -I is synonymous to hostname --all-ip-addresses which means it will show all IP address of all interfaces (except loopback).

In my computer, i have three configured interfaces (one is my physical (bridge) interface, one virtual interface for lxc and one virtual interface for docker), hence it shows:

% hostname -I 
10.0.3.1 172.17.42.1 192.168.6.4 

From man hostname:

-I, --all-ip-addresses Display all network addresses of the host. This option enumerates all configured addresses on all network interfaces. The loopback interface and IPv6 link-local addresses are omitted. Contrary to option -i, this option does not depend on name resolution. Do not make any assumptions about the order of the output.