Re: External IP address



slebetman@xxxxxxxxx wrote:
chawki.jreige@xxxxxxxxx wrote:

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

Which returns rubish if you sit behind a NAT gateway.

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
.



Relevant Pages

  • Re: External IP address
    ... There's probably a page on the wiki for this. ... You can do it with the http ... package require http ... Which returns rubish if you sit behind a NAT gateway. ...
    (comp.lang.tcl)
  • [Full-Disclosure] LNSA-#2004-0006: bug workaround for Apache 2.0.48
    ... Package name: apache ... The Apache HTTP Server Project is an effort to develop and maintain an ... We recommend that all systems with this package installed be upgraded. ...
    (Full-Disclosure)
  • LNSA-#2004-0006: bug workaround for Apache 2.0.48
    ... Package name: apache ... The Apache HTTP Server Project is an effort to develop and maintain an ... We recommend that all systems with this package installed be upgraded. ...
    (Bugtraq)
  • Re: Getting a file from http
    ... Is it is the same command with the ... HTTP version for this. ... You really should be doing "package require http" unless you are counting on ... I have been reading all man pages on http_get and cannot get it to ...
    (comp.lang.tcl)
  • Re: Getting a file from http
    ... You really should be doing "package require http" unless you are counting on some old behavior of the 1.x series. ... Is this the right command or do I use any other command? ... a token for that request - you can then use that token to get the return codes, meta data and also the data itself that was fetched, you can check the docs fdor this ...
    (comp.lang.tcl)