Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: how to find my own ip address
Pages: [1] Print
Author Topic: how to find my own ip address  (Read 1094 times)
nogoodboyo
Guest


Email
how to find my own ip address
« on: January 21, 2005, 10:38:15 AM »

Can anyone help with this? I want to find the internet address of a PC and email the result. The email bit I can do :->.
Thanks, NGB.
Logged
CarlRead
Full Member
***
Offline Offline

Posts: 105


View Profile
how to find my own ip address
« Reply #1 on: January 21, 2005, 11:27:01 PM »

I'm not sure what you mean.  PCs don't have an internet address, though servers running on them will have and when the computer connects to the internet they'll be given one, though it may not be the same address every time they connect.  (Depends on the ISP they're going though and so on.)

So, do you want to find out your own address, or someone elses somewhere out on the net?

To get addresses from domain names is simple...

Code:
>> print read dns://www.rebol.com
216.193.197.238
as is doing the reverse...

Code:
>> print read dns://216.193.197.238
rebol.com
If you have a server running with REBOL on it, you can get the address of those who visit a page, (meaning a page generated by one of your CGI scripts), by creating a script based on the info here...

http://www.rebol.com/docs/core23/rebolcore...ml#section-13.4

You could find your own address then by surfing to that page, or the addresses of any others you can entice there.

I don't know of other methods, but then network protocols are not my strong point.
 
Logged

- Carl Read
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
how to find my own ip address
« Reply #2 on: January 23, 2005, 05:31:12 AM »

If you only have one network interface, it may be enough for you to check system/network/host-address. Otherwise, since usually you are interested in the address of the interface connected to the Internet, the best way is:

Code:
port: open tcp://www.rebol.com:80
print port/local-ip

It's also possible to get a list of all the network interfaces in your PC:

Code:
port: open udp://
print mold get-modes port 'interfaces

Of course, if you're under NAT none of the above will help, if you want to know your public IP... Smiley
Logged
notchent
Newbie
*
Offline Offline

Posts: 40


View Profile WWW
Re: how to find my own ip address
« Reply #3 on: January 17, 2007, 12:25:04 AM »

This displays the current WAN and LAN IP addresses of your computer:

parse read http://whatismyip.com [thru <title> copy my-ip to </title>]
parse my-ip [thru "-" copy stripped-ip to end]
alert to-string rejoin ["WAN: " stripped-ip " ---- LAN: " read join dns:// read dns://]

( from http://musiclessonz.com/rebol.html )
Logged

Graham
Full Member
***
Offline Offline

Posts: 113


View Profile
Re: how to find my own ip address
« Reply #4 on: January 18, 2007, 04:19:24 AM »

Logged

notchent
Newbie
*
Offline Offline

Posts: 40


View Profile WWW
Re: how to find my own ip address
« Reply #5 on: January 20, 2007, 12:04:12 AM »

Hi Graham,

Is the source for that available?
Logged

Graham
Full Member
***
Offline Offline

Posts: 113


View Profile
Re: how to find my own ip address
« Reply #6 on: January 20, 2007, 12:30:55 PM »

Here it is .. unedited

Code:
#!/path/to/rebol -cs

REBOL [
    Title: "Find remote IP address"
    Date: 1-Jun-2001
    Version: 0.0.1
    File: %whatismyip.r
    Author: "Graham Chiu"
    Purpose: {
}
    History: [
]
    Category: [cgi ldc net tcp util 3]
    Examples: {
    }
    Note: {
    }
]

print "Content-type: text/html^/^/"

test: false ; system/options/cgi/remote-addr  ; enables local test mode

either test [
    cgi: context [
        remote-addr: "1.2.3.4"
        query-string: "cmd=post&service=chat&name=sean&data=9080"
    ]

][
    cgi: system/options/cgi
]

    ip: to-tuple cgi/remote-addr

if not error? try [ proxy-ip: to-tuple first parse select cgi/other-headers "HTTP_X_FORWARDED_FOR" "," ][
ip: proxy-ip
]

print [ <ip> ip </ip> ]
quit
Logged

notchent
Newbie
*
Offline Offline

Posts: 40


View Profile WWW
Re: how to find my own ip address
« Reply #7 on: January 21, 2007, 09:47:58 AM »

thanks!
Logged

Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: how to find my own ip address
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 07, 2008, 11:10:20 AM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2241 Posts in 585 Topics by 2232 Members
Latest Member: ThortHoTeMorY

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc