cancel
Showing results for 
Search instead for 
Did you mean: 

Obtaining Pluse Net Gateway identity within a web server-side script

Superuser
Superuser
Posts: 11,095
Thanks: 2,463
Fixes: 22
Registered: 22-08-2007

Obtaining Pluse Net Gateway identity within a web server-side script

Not sure if this should be here or in web hosting (the latter does not seem a good fit).
I want to be able to report my current PN Gateway on a page delivered by my (local) web server.  I know of the Plusnet Usergroup tool 'Which Gateway' (http://usertools.plus.net/@gateway) however that runs within their web pages and all I want is the result embedded in my web page as in 'pcl-ag01'.  The reason for doing this server-side is that I want to be able to see this information / web page when not at home on the PN network.
I guess I could (somehow) extract data from tracert...
Quote from: tracert

Tracing route to portal.plus.net [212.159.9.2] over a maximum of 30 hops:
  1    *        *        *    Request timed out.
  2  322 ms    79 ms    55 ms  lo0-central10.pcl-ag01.plus.net [195.166.128.182]
  3  196 ms    38 ms    36 ms  link11-central10.pcl-gw01.plus.net [84.93.249.20]
  4  196 ms    61 ms    36 ms  xe-0-2-0.pcl-cr01.plus.net [212.159.1.0]
  5  209 ms    36 ms    36 ms  po2.pcl-gw01.plus.net [195.166.129.41]
  6  266 ms    44 ms    44 ms  gi5-8.ptp-cr01.plus.net [84.93.224.48]
  7  245 ms    45 ms    45 ms  vlan2658.ptp-elb02.plus.net [84.93.224.45]
  8  205 ms    46 ms    45 ms  portal.plus.net [212.159.9.2]
Trace complete.

If the AP / modem supported TelNet I might beable to extract the data from there, however they do not support TelNet.  Would be ral nice ifthere were a PN cgi script which delivered just the gateway name for a given IP address or account name - e.g. http://plus.com/cgi/gateway.cgi?user=townman returns just the Gateway ID.
All seems a bit tedious - anyone got a workable suggestion please?
Cheers,
kevin
7 REPLIES
Community Veteran
Posts: 1,136
Thanks: 2
Registered: 30-07-2007

Re: Obtaining Pluse Net Gateway identity within a web server-side script

Warning: PHP ahead!
       $gateway_o = exec("netstat -rn -f inet | grep default");
       $gateway = preg_split("/\s+/",$gateway_o);
       $gateway_ip = $gateway[1];
       $gateway_host = gethostbyaddr($gateway_ip);
       $gateway_host_parts = explode(".",$gateway_host);
       $gateway_id = $gateway_host_parts[1];
Although you have to run that on the router...
(From the script that does my sig image)
F9 member since 4 Sep 1999
F9 ADSL customer since 27 Aug 2004
DLM manages your line the same way DRM manages your rights.
Look at all the pretty graphs! (now with uptime logging!)
Superuser
Superuser
Posts: 11,095
Thanks: 2,463
Fixes: 22
Registered: 22-08-2007

Re: Obtaining Pluse Net Gateway identity within a web server-side script

Avatastic,
Thanks for the suggestion - PHP is over my experience horizon and on the retirement bucket list to learn!  Crazy
After a bit of scrabbling around, I got the following asp / vbscript to do the job.  A bit Heath Robinson, but it works... others might find it useful.  Effectively it parses the results of tracert.
<%
Response.Buffer = true
url ="plus.net"
Set objWShell = CreateObject("WScript.Shell")
Set objCmd = objWShell.Exec("tracert -4 -h 4 -w 40 " & url)
strPResult = objCmd.StdOut.Readall()
Set objCmd = nothing:
Set objWShell = nothing
strResponseRows = split(strPResult, vbCRLF)
for i = 4 to ubound(strResponseRows)
  if instr(strResponseRows(i),url)>0 then
  strInterestingBit = mid(strResponseRows(i),33)
    strResult = split(strInterestingBit," ")
    strURL= split(strResult(0),".")
    response.write strURL(0) & "<br>"
    response.write strURL(1) & "<br>"
    response.write strResult(1) & "<br>"
exit for
  end if
next
%>

Produces...
lo0-central10<br>pcl-ag01<br>[195.166.128.182]<br>
Community Gaffer
Community Gaffer
Posts: 13,102
Thanks: 895
Fixes: 74
Registered: 04-04-2007

Re: Obtaining Pluse Net Gateway identity within a web server-side script

Quote from: townman
If the AP / modem supported TelNet I might beable to extract the data from there, however they do not support TelNet.

You can enable telnet on the WAN interface of the 582n using:
:service system ifadd name TELNET group wan
:mlp role addpriv name Administrator access anyaccess service anyservice
:saveall

Bob Pullen
Plusnet Products Team
If I've been helpful then please give thanks ⤵

csogilvie
Grafter
Posts: 5,852
Registered: 04-04-2007

Re: Obtaining Pluse Net Gateway identity within a web server-side script

If it's a server-side thing, just have a job which talks to http://usertools.plus.net/@gateway/ and extracts the results?
Edit: You'd think I'd know URLs for things that I've been involved in building :/
Superuser
Superuser
Posts: 11,095
Thanks: 2,463
Fixes: 22
Registered: 22-08-2007

Re: Obtaining Pluse Net Gateway identity within a web server-side script

Hi Bob,
Happy New Year to you...
Thanks for this contribution, even though it does not help me here.  I've ditched the TG585v8 as I suspect it is part of the problem I'm toying with elsewhere with Anotherone.  I do not have the 582n, not too sure it would help anyway other than exposing Bits & Tone data.
Do I correctly conclude that these commands make the TELENT interface remotely accessible ove rthe WAN interface?  If so than this might offer the means of undertaking remote RouterStats data collecting in situations where (for whatever reasons) RouterStats cannot be run locally.
Cheers,
Kevin
Plusnet Alumni (retired) chrispurvey
Plusnet Alumni (retired)
Posts: 5,369
Fixes: 1
Registered: 13-07-2012

Re: Obtaining Pluse Net Gateway identity within a web server-side script

Hi Kevin,
Yeah, you'll be able to access your router remotely after running the telnet commands.
houlton23
Grafter
Posts: 268
Registered: 22-05-2011

Re: Obtaining Pluse Net Gateway identity within a web server-side script

I've just implemented this on my server in PHP. If anyone wants the code let me know Smiley
Linky.
Alex Smiley