In article <pan.2002.05.14.14.36.26.727673.6068 / hotmail.com>, Seth Harper wrote:
> I'm attempting to write a small script that retrieves a servers 
> external IP adress, but I keep comming up with it's subnet IP, any 
> suggestion on how to grab the external IP? Thank you much :)
> 
> Here's the Code for returning the the IP from the hostname:
> 
> host = Socket.gethostname
> IP = IPSocket.getaddress(host)

Do you know the name of the external interface?  It may be different from
what's returned by hostname.

[mike@rand mike]$ irb
irb(main):001:0> require 'socket'
true
irb(main):002:0> packed_ip = Socket.gethostbyname('www.stok.co.uk')[3]
"K5"
irb(main):003:0> packed_ip.unpack('C*').join('.')
"209.251.75.53"

(though I'm sure there must be an ntoa style function to do the packed
4 bytes -> String somewhere...)

[mike@rand mike]$ host www.stok.co.uk
www.stok.co.uk is an alias for stok.co.uk.
stok.co.uk has address 209.251.75.53

Hope this helps,

Mike

-- 
mike / stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       | GPG PGP Key      1024D/059913DA 
mike / exegenix.com                  | Fingerprint      0570 71CD 6790 7C28 3D60
http://www.exegenix.com/           |                  75D2 9EC4 C1C0 0599 13DA