Re: External IP address



Uwe Klein wrote:
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

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.

.



Relevant Pages

  • Re: External IP address
    ... You can do it with the http ... package require http ... Which returns rubish if you sit behind a NAT gateway. ... my workplace, ifconfig: 172.30.28.250 ...
    (comp.lang.tcl)
  • Re: External IP address
    ... proc ip:adr { ... There's probably a page on the wiki for this. ... You can do it with the http ... package require http ...
    (comp.lang.tcl)
  • Re: External IP address
    ... proc ip:adr { ... There's probably a page on the wiki for this. ... You can do it with the http ... package require http ...
    (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)