In Linux, using a Bash Terminal, I can do:
hostname -d
to display the name of the DNS domain, andhostname -i
to display the network address(es) of the hostname .
How can I retrieve the same information–preferably using a single command (with option, if needed), and without having to elevate privileges–from a Bash terminal in Mac OS X?
For reference, here's the Bash Version I'm using in Mac OS X:
- GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15) .
Best Answer
For the
hostname -d
, usehostname -f
:For IP-addresses, use
ifconfig -a
(look for theinet
data). Your machine may have only one network device,en0
, so you could do justIf you are interested in all of the network devices, keep in mind that
ifconfig -l
lists the devices. This lists the devices and their correspond addresses:Further reading: