Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

ip and router

by nathanvit (Beadle)
on May 26, 2003 at 16:08 UTC ( [id://260851]=perlquestion: print w/replies, xml ) Need Help??

nathanvit has asked for the wisdom of the Perl Monks concerning the following question:

Hello everybody:

Situation:cisco router which protects little lan; lan with a linux server and a lot of linux/windows client.

Router is accessible via internet but i've no control on it and it automatically changes ip every day. I can only access via ssh but ssh requests are redirect on linux server

I'd want this goal:Admin server linux at home via ssh. It is simple if you know router's ip that redirect you on server but it changes!!

My solution: i thought to send an email to a fake account from the linux server so, when the mail arrives, router's ip is inside it. Make a perl script which connect to pop server of fake account probably with Mail::BOX::Pop3 module (which i've never used), get the message and bring the router's IP and then send it to my personal account...

My question:I thinks it is not good... Is there a module which can do that directly?

  • get ip form router
  • send it to my personal account
Note that i've no control on router and when i telnet on it from the lan there is a testual menu' which lets me to admin it parameters but i've not enough experience to manage them...

Replies are listed 'Best First'.
Re: ip and router
by Limbic~Region (Chancellor) on May 26, 2003 at 17:05 UTC
    nathanvit,
    I do not like this one bit - you really need to consider what could go wrong and try to develop a solution with that stuff in mind. For instance - is the reason the router changes it's IP everyday for security? If yes, you are now sending the IP in an email over the Internet. Only you will know the things that could go wrong, so I won't get up on a soapbox.

  • Create an alias that pipes the email to a script getip : "| /usr/local/bin/get_ip.pl"
  • In the get_ip.pl script, have it ping your broadcast 192.168.0.255 for instance
  • Have the script then perform an arp -a
  • You will have to hardcode the MAC address of the router so it will know what to look for - use a regex to extract the IP address
  • Finally, have the script send the IP to your home address system("echo $ip | mailx -s "today's IP" youraccount\@nowhere.com");

    Best of luck - L~R

      Would not a simple crontab entry on the private-network linux box work?

      0 23 * * * echo "message" | mailx -s "xx" account@some.place
      Then, just intercept the incoming mail message and parse it for the IP address...

      This is no more insecure (in terms of sending the IP across the network) than sending any other mail through the router.

      hmm.

      i agree that it's wierd for a router to change it's IP though....

        914,
        An email message doesn't retain the IP address of the router's that it was routed through - only the MTAs. There is no guarantee of this since any MTA can strip those headers (that's how remailers work).

        While this would work in a script that gets the IP before sending the email- it adds several new security concerns. What happens if nathanvit forgets to shut off the cronjob before going on vacation. He isn't around to monitor his email and his mailbox fills up - where does the undeliverable go?

        This is just plain bad juju - I don't like this one bit, I do not like it Sam I am.

        L~R

Re: ip and router
by Abigail-II (Bishop) on May 26, 2003 at 16:42 UTC
    That's a weird situation. Anyway, if the router changes it's IP-address, it needs to broadcast that change to the world somehow; if it wouldn't, packets would not be able to reach it. Before implementing any kludge way, I would first find out what this router is exactly doing, and why. Once you know that, you might be able to use a more reliable solution.

    Note that adminning a box through a router that changes its IP address on a regular basis is at best tricky, and you might find yourself locked out. When the router changes IP address, all your open connection are suddenly stale.

    Abigail

Re: ip and router
by castaway (Parson) on May 26, 2003 at 17:24 UTC
    I'm guessing your router changes IPs every day, because its an ISP with 24hour uptime and it gets cut off every day? (Mines like that, anyway..) If you can't influence the router to send you a mail or use a dynodns.net type thing, then thats a little difficult.. Or can you get the router to send a mail? (Mine does a ifconfig | mail my@work.address -s IP in it's ip-up.local)
    For telnetting to the router and using that text-menu (from inside the network) you might be able to use Net::Telnet and Expect ..

    C.

Re: ip and router
by arthas (Hermit) on May 26, 2003 at 18:06 UTC
    I think you can create an account on DynDns or No-Ip (the basic service is free), and install the client on a Windows or Linux machine of your LAN. This client will let DynDns/No-Ip know your address every now and then (you choose how frequently). Then, from the outisde, you just need to dig something like nathanvit.no-ip.org to know the IP address of your router.

    The solution isn't Perl based, but it's easy and should work smoothly.

    Michele.
Re: ip and router
by ScooterQ (Pilgrim) on May 27, 2003 at 14:11 UTC
    It sounds to me like you need ddclient (a perl solution!) in conjunction with dyndns.org. Depending on which Cisco you have you support might be built in to query the router directly.
    http://www.dyndns.org/services/dyndns/clients.html

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://260851]
Approved by Thelonius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-25 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found