From: Todd Benson Date: 2012-10-08T03:15:20+09:00 Subject: Re: know my IP in LAN On Sun, Oct 7, 2012 at 12:20 PM, ajay paswan wrote: > Hi how can I know my IP through which two computers communicate in LAN? > Like in socket, I wanna send my IP to the target machine. > > -- > Posted via http://www.ruby-forum.com/. You can can use the system method, as in... system "" But, you can easily do it without forking another shell. Somebody else wrote this... require 'socket' def local_ip orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily UDPSocket.open do |s| s.connect '64.233.187.99', 1 s.addr.last end ensure Socket.do_not_reverse_lookup = orig end p local_ip It checks the ip it would use to route to a random address without out sending any packets. Todd