Skip to content

Instantly share code, notes, and snippets.

@tomoyukiinoue
Created October 15, 2012 12:16
Show Gist options
  • Save tomoyukiinoue/3892167 to your computer and use it in GitHub Desktop.
Save tomoyukiinoue/3892167 to your computer and use it in GitHub Desktop.
Get own private IP address
require 'socket'
def my_first_private_ipv4
Socket.ip_address_list.detect{|intf| intf.ipv4_private?}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment