Page 3 of 3 FirstFirst 123
Results 21 to 28 of 28

Thread: Find my router's external IP

  1. #21
    Join Date
    Jun 2011
    Location
    Atlanta Georgia
    Beans
    1,769
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Find my router's external IP

    Ok so as a few have already said, if you want a local solution you have a few alternatives , and they can only occur if your router supports them.

    You mentioned you had a Linux router at one point, you could log into that router, either via telnet or ssh I'm sure. For a local solution you would have to do something along these lines (which has been mentioned already)

    You could write a script that logs in via telnet/ssh and basically grabs the ifconfig for the interface in question, and sticks it in a file on your computer and or dumps the output to the console.

    You could write a script that logs in via http/https and greps the interfaces page, grabs your external ip and dumps it to a a file on your computer or the console.

    As far as internal solutions those are your options. The http/s method will work on most routers even if they don't support telnet, it's going to be a pain, and you're going to have to use something like wget or curl to do it. However, you would not have to leave the local network in terms of packet traffic.

    If that's not good enough then I don't know what you want, because I don't think it exists. As far as how to do either of the above, it depends entirely on what router you have and what services it supports.

  2. #22
    Join Date
    Jul 2006
    Beans
    103

    Re: Find my router's external IP

    Guys, many thanks again for all the answers. This is very enlightening for me

    Quote Originally Posted by Dangertux View Post
    You could write a script that logs in via telnet/ssh and basically grabs the ifconfig for the interface in question, and sticks it in a file on your computer and or dumps the output to the console.
    This is kind of what I had in mind, but It was only a blurred idea, so thanks for the tip on ifconfig. I'll investigate further into invoking ifconfig from telnet

    Quote Originally Posted by Dangertux View Post
    You could write a script that logs in via http/https and greps the interfaces page, grabs your external ip and dumps it to a a file on your computer or the console.

    As far as internal solutions those are your options. The http/s method will work on most routers even if they don't support telnet, it's going to be a pain, and you're going to have to use something like wget or curl to do it. However, you would not have to leave the local network in terms of packet traffic.
    So I'd log into my router with http(s), and it would be strictly local? Then I guess there is a http(s) server running into my router.. very interesting, thanks

  3. #23
    Join Date
    Jun 2011
    Location
    The Shadow Gallery
    Beans
    6,744

    Re: Find my router's external IP

    Quote Originally Posted by Roque View Post
    Guys, many thanks again for all the answers. This is very enlightening for me


    This is kind of what I had in mind, but It was only a blurred idea, so thanks for the tip on ifconfig. I'll investigate further into invoking ifconfig from telnet


    So I'd log into my router with http(s), and it would be strictly local? Then I guess there is a http(s) server running into my router.. very interesting, thanks
    All of this would work, but it means connecting to your router which i what i said in my first response in post #4

    Just connect to your routers interface and it will tell you the WAN IP, same as Telnetting into it.

    just go to x.x.x.x IP address in your address bar and log into it.

    Which has been said already
    Backtrack - Giving machine guns to monkeys since 2006
    Kali-Linux - Adding a grenade launcher to the machine guns since 2013

  4. #24
    Join Date
    Jul 2006
    Beans
    103

    Re: Find my router's external IP

    Quote Originally Posted by haqking View Post
    All of this would work, but it means connecting to your router which i what i said in my first response in post #4

    Just connect to your routers interface and it will tell you the WAN IP, same as Telnetting into it.

    just go to x.x.x.x IP address in your address bar and log into it.

    Which has been said already
    That would mean firing up the browser, logging into the router, switching to the right tab in the web interface, etc. Too slow, plus this way you can't automatize any further task involving the obtained IP

    Anyway, it's solved now (locally and fully automatically). Many thanks to all for your kind help

  5. #25
    Join Date
    Jul 2011
    Location
    UK
    Beans
    4
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Find my router's external IP

    How did you solve it in the end?

  6. #26
    Join Date
    Mar 2007
    Location
    Denver, CO
    Beans
    7,958
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Find my router's external IP

    This thread was originally written like 1 year ago. I'm highly doubting the guy is going to answer.

  7. #27
    Join Date
    Jun 2011
    Location
    The Shadow Gallery
    Beans
    6,744

    Re: Find my router's external IP

    Quote Originally Posted by kevdog View Post
    This thread was originally written like 1 year ago. I'm highly doubting the guy is going to answer.
    5 months ago and the OP last reply was 3

    oh and was last active 2 weeks ago.

    no reason why the OP wouldnt respond to their own thread whenever it was created, i know i do.
    Last edited by haqking; January 18th, 2012 at 03:20 PM.
    Backtrack - Giving machine guns to monkeys since 2006
    Kali-Linux - Adding a grenade launcher to the machine guns since 2013

  8. #28
    Join Date
    Apr 2012
    Beans
    1

    Re: Find my router's external IP

    This is my quick and simple solution in perl (set proxy server if you have one):

    Code:
    #!/usr/bin/perl
    
    use LWP::UserAgent;
    
    ################################################################################
        
        my $page       = 'http://checkip.dyndns.org';
        
        my $use_proxy  = 1;
        my $proxy      = 'proxy_string';
        my $proxy_port = '80';
        my $username   = 'username_string';
        my $password   = 'password_string';
        
    ################################################################################
    
    
    my $browser = LWP::UserAgent->new;
    
    if($use_proxy == 1){
        $browser->proxy('http', "http://$username:$password\@$proxy:$proxy_port/");
    }
    
    my $response = $browser->get("$page");
    
    die "\n\nError: ", $response->status_line, "\n\n" unless $response->is_success;
    
    my $output = $response->content;
    
    my ($external_ip) = ($output=~/Current IP Address: (\d+\.\d+\.\d+\.\d+)/);
    
    print("\n\nExternal IP: $external_ip\n\n");
    
    exit(0);

    You can place the script in any server in your private network to work.
    Last edited by coffeecat; April 20th, 2012 at 08:10 PM. Reason: Added code tags and removed hard to read colour.

Page 3 of 3 FirstFirst 123

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •