I have searched everywhere but their solution requires some form of IP address. Here are the solutions i have found.
require \'socket\' #METHOD 1 ip
require 'socket' Socket::getaddrinfo(Socket.gethostname,"echo",Socket::AF_INET)[0][3]
quite like method 1, actually