# !/usr/bin/ruby -w # # (c)2006 Suninny's Rails Theme # # http://blog.csdn.net/rails # # #################################### require ' socket ' require ' open-uri ' inner_ip = Socket.getaddrinfo(Socket.gethostname, Socket::AF_INET)[0][ 3 ]html = URI.parse( " http://www.whatismyip.com " ).readouter_ip = html.scan( / (([0 - 9 ]{ 1 , 3 }.?){ 4 }) / ).flatten.firstputs " 内网IP地址:#{inner_ip} " puts " 外网IP地址:#{outer_ip} "