Search This Blog


Get IP Address from Commandline in Linux

There are multiple ways to hack together fetching an IP address for each interface.

But one of the easiest ways that I've recently learned about is using the hostname command


hostname -I


hostname --all-ip-addresses

Will as the man page says

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.

This will not show you which interface has which IP but it will show you which IPs are configured which is useful in some scenarios.


No comments:

Post a Comment