#128159 - 2004-10-20 08:53 AM
Extrenal IP address
|
guytje
Fresh Scripter
Registered: 2004-10-15
Posts: 7
|
Does somebody know how to get via a kix-script the external IP address if you are using a router ?
The IP-address you are using on the net.
Many thanks.
|
|
Top
|
|
|
|
#128161 - 2004-10-20 12:43 PM
Re: Extrenal IP address
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Do you mean the address of the router, i.e. the gateway?
If so, look at EnumIPInfo() for one method - you will want to retrieve type "3".
For example: Code:
"Default gateway: "+EnupIPInfo(0,3)+@CRLF
If you want to know the routers WAN ip address, you will need to resort to SNMP or scripted login to the router.
Tracert may also give you the information you require, for example: Code:
c:\> tracert www.microsoft.com
Explain a little bit more about what you are looking for, and why.
|
|
Top
|
|
|
|
#128163 - 2004-10-20 03:21 PM
Re: Extrenal IP address
|
guytje
Fresh Scripter
Registered: 2004-10-15
Posts: 7
|
Dear Richard,
I would like to know my external IP address. That's the address, I have received from my ISP. (via internet explorer, you can retrieve it via http://www.showmyip.com) Due to the fact that I'm connected with the internet via a router, I can't take the IP address of the computer because it's a local one.
The reason why I would like to know is, I would like to build a program which is informing me when my external IP address is changed.
Thanks,
Guy
|
|
Top
|
|
|
|
#128165 - 2004-10-20 03:41 PM
Re: Extrenal IP address
|
guytje
Fresh Scripter
Registered: 2004-10-15
Posts: 7
|
Les,
Ok, you use www.ipchicken.com, but can you integrate this in a kix-script which is checking when an external address is changing.
Guy
|
|
Top
|
|
|
|
#128166 - 2004-10-20 03:41 PM
Re: Extrenal IP address
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
In that case, the options (in my personal order of preference) would be:
- SNMP query
- Automated router web based management query (as Cybex suggested)
- Scripted telnet / ftp
- Automated web IP query
What router are you using?
|
|
Top
|
|
|
|
#128167 - 2004-10-20 03:42 PM
Re: Extrenal IP address
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
Les,
Ok, you use www.ipchicken.com, but can you integrate this in a kix-script which is checking when an external address is changing.
Guy
Yes.
|
|
Top
|
|
|
|
#128169 - 2004-10-20 03:51 PM
Re: Extrenal IP address
|
guytje
Fresh Scripter
Registered: 2004-10-15
Posts: 7
|
Router is a SMCrouter type SMC7004BVR.
But then the script can only be used with this router. I'm more looking for a general script.
|
|
Top
|
|
|
|
#128170 - 2004-10-20 03:56 PM
Re: Extrenal IP address
|
guytje
Fresh Scripter
Registered: 2004-10-15
Posts: 7
|
Jochen,
No it isn't showing with the dos-command ipconfig /all, that's the problem.
Regards,
Guy
|
|
Top
|
|
|
|
#128171 - 2004-10-20 04:07 PM
Re: Extrenal IP address
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
This is a simple demo which works with the www.ipchicken.com site.
It sometimes chokes as it is looking for an HTML "BOLD" command - if this isn't present on the page it returns an incorrect value.
You can use this with a bit of error checking, or if you can find a site which uses named objects on the page you should be able to get a cleaner result.
Code:
$=SetOption("WrapAtEOL","ON") $=SetOption("ASCII","ON") $oIE = CreateObject("internetexplorer.application") $oIE.Visible = 0 $oIE.Navigate("www.ipchicken.com") While $oIE.busy AND $oIE.readystate <> 4 AND @ERROR = 0 Loop $oDoc=$oIE.document $sHTML=$oDoc.body.innerHTML $oIE.Quit() $oIE = 0 ; Strip out IP address. $sIP=SubStr($sHTML,InStr($sHTML,'<B>')+3) $sIP=Left($sIP,InStr($sIP,' ')-1) $sIP ?
|
|
Top
|
|
|
|
#128172 - 2004-10-20 04:11 PM
Re: Extrenal IP address
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
...even simpler (and more reliable) with the other site... Code:
$=SetOption("WrapAtEOL","ON") $=SetOption("ASCII","ON") $oIE = CreateObject("internetexplorer.application") $oIE.Visible = 0 $oIE.Navigate("http://checkip.dyndns.org/") While $oIE.busy AND $oIE.readystate <> 4 AND @ERROR = 0 Loop $oDoc=$oIE.document $sHTML=$oDoc.body.innerText $oIE.Quit() $oIE = 0 ; Strip IP Address $sIP=SubStr($sHTML,InStr($sHTML,':')+2) $sIP ?
|
|
Top
|
|
|
|
#128173 - 2004-10-20 05:22 PM
Re: Extrenal IP address
|
guytje
Fresh Scripter
Registered: 2004-10-15
Posts: 7
|
Richard,
It's working.
Many thanks.
Guy
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 661 anonymous users online.
|
|
|