Re: External IP address
- From: "slebetman@xxxxxxxxx" <slebetman@xxxxxxxxx>
- Date: 15 Dec 2006 02:31:55 -0800
Uwe Klein wrote:
slebetman@xxxxxxxxx wrote:
chawki.jreige@xxxxxxxxx wrote:Which returns rubish if you sit behind a NAT gateway.
I use the following code to obtain the local IP address of my server:
proc ip:adr {} {
set me [socket -server xxx -myaddr [info hostname] 0]
set ip [lindex [fconfigure $me -sockname] 0]
close $me
return $ip
}
How would I obtain the external IP address?
There's probably a page on the wiki for this. But my favourite method
is to query http://checkip.dyndns.com. You can do it with the http
package:
package require http
set f [http::geturl http://checkip.dyndns.com]
set raw [http::data $f]
http::cleanup $f
regexp -- {(\d+\.\d+\.\d+\.\d+)} $raw --> ip_address
puts $ip_address
my workplace, ifconfig(eth1): 172.30.28.250
Not what the OP wanted. The OP already has a script for this.
my workplace, your script: 84.144.214.55
Which is exactly what the OP wanted.
Read carefully: the OP specified the "external" IP address which I
interpreted as the public IP, one attached to the NAT gateway.
.
- Follow-Ups:
- Re: External IP address
- From: slebetman@xxxxxxxxx
- Re: External IP address
- From: Uwe Klein
- Re: External IP address
- References:
- External IP address
- From: chawki . jreige
- Re: External IP address
- From: slebetman@xxxxxxxxx
- Re: External IP address
- From: Uwe Klein
- External IP address
- Prev by Date: Re: Gracefully stopping an infinite loop after a particular keyboard input
- Next by Date: Re: Why I need to click twice to destroy a top level window?
- Previous by thread: Re: External IP address
- Next by thread: Re: External IP address
- Index(es):
Relevant Pages
|