Interesting Network Problem

Discussion in 'OT Technology' started by 5Gen_Prelude, Mar 12, 2004.

  1. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    What I need to know is the public IP address of one of our routers (linksys) in a regional office. It's on one of those ISP plans that changes the IP every once in awhile (the IP was good for a couple of months and then it dropped). I have access to the computers behind the router, but only when I know the public IP. I can set something up from behind the router to send to me (via email or whatever) to update me on what the Public IP is, but how do I find out what the WAN IP is from behind the router? I tried tracert, but the first hop times out and reports back no IP address until it hits the router's gateway. Another way is to look at our FTP server logs to find out what the source IP is since it does send data every other day. This does work but the logs are a pain in the ass to get (not served locally), and I have to make a guess on which one is the proper DNS name (not that difficult but still not a very slick way of doing it). I'm looking for something automatic that can be run on a schedule via the command prompt (like my tracert idea - but one that works).

    Any ideas?
     
  2. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    cant u rarp the MAC it for an ip address?
     
  3. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Perhaps - how would I do that? I know both MAC addresses, but the WAN IP is variable and the LAN behind the router doesn't see it.
     
  4. sm0ke

    sm0ke OT's Stargate expert.

    Joined:
    Aug 8, 2003
    Messages:
    4,575
    Likes Received:
    0
    Location:
    ATX
    i belive if you send an e-mail to yourself from inside the router, check the headers and the IP of the router should be in there. although i am unsure which one it will be. but do some investigating and it should turn up.
     
  5. Leb_CRX

    Leb_CRX OT's resident terrorist

    Joined:
    Apr 22, 2001
    Messages:
    39,994
    Likes Received:
    0
    Location:
    Ottawa, Canada
    not sure if I understood the question exactly, but www.whatismyip.com would give you that info :hs:

    but I dont know any way to script that
     
  6. Wolf68k

    Wolf68k OT Supporter

    Joined:
    Dec 18, 2003
    Messages:
    4,861
    Likes Received:
    2
    Location:
    Houston, Texas
    If you can login into the router, there is an area in your router settings called something along the lines of 'status'. It's where you can release and renew the WAN IP address, and also see the WAN IP address along with the DNS IP addresses and lease time and a few other things.

    http://www.ipchicken.com is also a good place to go online to find out the WAN IP address.
     
  7. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    This might work actually, run that webpage and it should return the WAN IP. Like you say, just a matter of parsing the IP from the page and sending it off. :coold:
     
  8. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Thanks, but the router is not accessible unless I know the WAN IP since the router is on the other side of the country.
     
  9. Leb_CRX

    Leb_CRX OT's resident terrorist

    Joined:
    Apr 22, 2001
    Messages:
    39,994
    Likes Received:
    0
    Location:
    Ottawa, Canada
    very interesting, hey you know what I have a program that will do that for ya it's about 90% done, I just remember it can read that info from one of the computers behind the router and email it to you! It was the challenge astro posted that was suppose to be done in PHP but I did it with C#....retreives page, and emails it...so ya let me know if your interested, i'll finish it up for ya (and custom tailor it), tops 2-3 days and it should be working :eek3d:
     
  10. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    All I need is the IP. Stick that in a text file and I'll do the rest (since I probably want to FTP the file so I can automatically retrieve it). That be great :bigthumb:
     
  11. Leb_CRX

    Leb_CRX OT's resident terrorist

    Joined:
    Apr 22, 2001
    Messages:
    39,994
    Likes Received:
    0
    Location:
    Ottawa, Canada
    how is this so far??

    do you wnat something to keep updating it every certain amount of time?

    [​IMG]
     
  12. Rob

    Rob OT Supporter

    Joined:
    Jul 6, 2002
    Messages:
    88,621
    Likes Received:
    39
    Location:
    Atlanta, GA
  13. JaggedEdge

    JaggedEdge ???????????? OT Supporter

    Joined:
    Jul 9, 2002
    Messages:
    1,566
    Likes Received:
    0
  14. Leb_CRX

    Leb_CRX OT's resident terrorist

    Joined:
    Apr 22, 2001
    Messages:
    39,994
    Likes Received:
    0
    Location:
    Ottawa, Canada
    I already got the parsing part done and what not....but your righth ad I known about that it would of been easier

    just wait for the pic to load in my previous post, slow server :hs: :wtc:
     
  15. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    5Gen: How do you want to access the IP at the time you need it?
     
  16. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    A computer on the other side of the router sends data via FTP on a regular basis already so I can send the IP data at the same time. I'd like to be able run a progam such as

    c:\GETWANIP.exe c:\ip.txt

    where c:\ip.txt is the filename (although I really don't care if the filename is variable). The key is that it requires no user intevention whatsoever.
     
  17. Leb_CRX

    Leb_CRX OT's resident terrorist

    Joined:
    Apr 22, 2001
    Messages:
    39,994
    Likes Received:
    0
    Location:
    Ottawa, Canada
    ok how about we just make the default file go in c:\ip.txt...I'll try to get it to pass data from teh command line but I made it gui...oops I'll see if I can transfer the code
     
  18. Leb_CRX

    Leb_CRX OT's resident terrorist

    Joined:
    Apr 22, 2001
    Messages:
    39,994
    Likes Received:
    0
    Location:
    Ottawa, Canada
    program finished...as repested ;)

    i'll give you link in a bit just gonna test it!
     
  19. Leb_CRX

    Leb_CRX OT's resident terrorist

    Joined:
    Apr 22, 2001
    Messages:
    39,994
    Likes Received:
    0
    Location:
    Ottawa, Canada
  20. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    mscoree.dll not found - I'll check back tomorrow since I don't have time to d/l it.
     
  21. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Sweet - works locally. I wonder if I need to install .NET framework or just that one DLL? 22MB of crap from MS seems a tad excessive to fetch the IP :rofl:. I still need to test it on the remote machine which I'll do this afternoon when they've gone home.

    PS Thanks for the command line change too - although I was wondering why it didn't work the first couple of times without it :bigthumb:
     
  22. Leb_CRX

    Leb_CRX OT's resident terrorist

    Joined:
    Apr 22, 2001
    Messages:
    39,994
    Likes Received:
    0
    Location:
    Ottawa, Canada
    glad you like it, if you need anything else changed, holla, I love programming jsut dont do it very often because I dont have many projects to do :o
     
  23. col_panic

    col_panic calm like a bomb Moderator

    Joined:
    Sep 19, 2003
    Messages:
    188,160
    Likes Received:
    0
    Location:
    winter haven, fl
    you could write a script that uses lynx and grep to grab that
     
  24. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Well since you asked... :big grin:

    - some error checking to ensure that if no IP address is found or the website cannot be reached or resolved that it does NOT write the file.
    - And now that I know how I'm going to use this info, it would be handy to have a second cmd line entity that would allow a DNS name to be provided. If the 2nd cmd line entity exists, then output the IP address, then a tab, then the DNS name supplied. This would allow me to append the text file to the end of the hosts file.

    But you've done plenty, this will do as it is so don't feel like you have to or anything.
     
  25. Leb_CRX

    Leb_CRX OT's resident terrorist

    Joined:
    Apr 22, 2001
    Messages:
    39,994
    Likes Received:
    0
    Location:
    Ottawa, Canada
    I will do the IP check when I get soem time, but I am not clear on the DNS entry

    so like
    getwanip c:\file.txt 1
    1 = get DNS

    now you mean just get the DNS server your using? and parse it at after a tab?
    for example...now anyone know any easy ways to get the DNS server? :hs:
    :
    x.x.x.x DNS server
     

Share This Page