Bash function for getting local IP on OSX

Below is a handy little bash function that returns your local IP address on OSX (and maybe elsewhere). Just pop the following in your .profile.

### Get local IP ###
function ip {
  ipconfig getifaddr en1

1 thought on “Bash function for getting local IP on OSX”

  1. The function, as written, failed to return the IP address of my MBP running OS X 10.9.1. After poking around a bit, I was able to modify the function to work. Also, rather than inserting the snippet into .profile, I added it to .bash_profile. This is working for me:
    function ip {
    ifconfig en0

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.