I am writing a Bash script that requires the internal/private IP address. On a Linux system I normally use the hostname -I
command. However, this does not work on some other Unix-like systems, most notably MacOS.
Is there any command that does return the private IP address, that is present on most (if not all) Unix-like systems?
Asked
Active
Viewed 43 times
1

Lukas
- 57
hostname -I
returns all of them, though only the IPv4 ones (at least not the link-local IPv6 ones), and it seems to exclude the address of the loopback interface. – Stéphane Chazelas Feb 09 '22 at 19:41hostname -I
depending on what exactly you want to do) – Stéphane Chazelas Feb 09 '22 at 19:48