Re: External IP address
- From: Uwe Klein <uwe_klein_habertwedt@xxxxxxxxxxx>
- Date: Fri, 15 Dec 2006 10:45:08 +0100
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
my workplace, your script: 84.144.214.55
which is the currently assigned IP of my DSL lease on
my gateway box.
uwe
.
- Follow-Ups:
- Re: External IP address
- From: slebetman@xxxxxxxxx
- Re: External IP address
- References:
- External IP address
- From: chawki . jreige
- Re: External IP address
- From: slebetman@xxxxxxxxx
- External IP address
- Prev by Date: Gracefully stopping an infinite loop after a particular keyboard input
- Next by Date: Re: About TIP#214: Add New Object Introspection Command
- Previous by thread: Re: External IP address
- Next by thread: Re: External IP address
- Index(es):
Relevant Pages
|