In Ruby, how does one get their IP octet without going through DNS?
- by user30997
I can, on some of my systems, get my IP address (192.68.m.n format) by doing this:
addr = IPSocket::getAddress(Socket.gethostname())
...the trouble is that this only works if the name the local machine uses for itself is the name the DNS server associates with it.
How *&#( hard can it be for ruby to just return its primary interface's IP address? I have to do this in a platform-independant way or I'd just call ifconfig or ipconfig and parse it.