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
}

One Reply to “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 Reply

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