Thursday, April 23, 2009

Check your IP address in Linux or OS X

Curious about what you IP address is on your Linux or OS X machine? Type this at the Terminal:
Some Linux distros, like CentOS, don't have this command as a part of the PATH environment variable so type this instead:
You will see a lot of information after running this command. The line or lines you are looking for begin with the letters "en" and will be followed by a number. The line below this that begins with "inet" has your IP address. If you are on a home network it probably looks something like this: 192.168.x.x, where the x's are replaced with numbers. On my laptop I have a ton of information that gets dumped to the console when I run this command because of all the virtual machines I have so I made a shortcut. I added this line to my .bashrc file:
alias ip='ifconfig en0|grep "inet ";ifconfig en1|grep "inet " '
My laptop has two network interfaces that I care about, "en0" is my wired ethernet and "en1" is my wireless. All I have to do is type "ip" at the Terminal and just that line with the IP address in it for each network adapter and only if it is connected. So I I am using just my wireless and I run this command then I will only get the line corresponding to my wireless IP address but if I am using my wireless and wired network adapters simultaneously and I run this command then I will see both IP addresses.

Your system may be a bit different depending upon how many network adapters you have. My desktop, for example, has three wired ethernet adapters in it so for it the alias line looks like this:
alias ip='ifconfig en0|grep "inet ";ifconfig en1|grep "inet ";ifconfig en2|grep "inet " '

1 comment:

  1. Thanks for the information...I used it and knew my network IP...I even confirmed it with


Note: Only a member of this blog may post a comment.