Get Local Ip
Join the DZone community and get the full member experience.
Join For Free// gets the local IP of a linux machine
def local_ip
ifconfig = %x(which /sbin/ifconfig).strip
%x(ifconfig).split("lo").shift =~ /inet addr\:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s/
$1
end
Opinions expressed by DZone contributors are their own.
Comments