Skip to content

Instantly share code, notes, and snippets.

@moro
Created September 8, 2008 04:47
Show Gist options
  • Save moro/9375 to your computer and use it in GitHub Desktop.
Save moro/9375 to your computer and use it in GitHub Desktop.
#
# get current IP addr.
# reject internal netwok(eg. vmnet0, for VMware) at the end of method chain.
# is there better way?
#
Socket.getaddrinfo(Socket.gethostname, 0, Socket::AF_INET).
map{|e| e[2] }.
uniq.
reject{|addr| addr =~ /\.1\Z/ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment