Jump to content

Message my PC when the router grants an IP address


mshenoy
 Share

Recommended Posts

So my setup is a Linksys WRT160 N and 2 machines 1 running a windows xp and another an Ubuntu 8.10.

I want to know if there is a way that the router can send a message to my PC when it receives a DHCP request and grants it an IP address. Like for instance when the IP address is granted it has the MAC address too so it sends a message "YOUR IP (internal or external is 0.0.0.0) "

Now, I know the router (WRT160n) has a log of the DHCP requests with the mac addresses and the IP addresses as well.

Since I have an Ubuntu machine could I access this log through the machine and have a cron job running to check for IP addresses assigned or could this be done through the Router by its own.

I just care about the messaging functionality...I am sure there is a way ....I am looking into it....but do any of you guys know how this could be accomplished ??

Link to comment
Share on other sites

Many routers will send logs to a email address. This possibly will do what you require depending on if emails can be sent using DHCP requests as a trigger. Alternatively, this information may be available from the router using SNMP.

The alternative that doesn't involve the router at all would be to run tcpdump (or some thing like that) and trigger an event on DHCP requests.

Link to comment
Share on other sites

Many routers will send logs to a email address. This possibly will do what you require depending on if emails can be sent using DHCP requests as a trigger. Alternatively, this information may be available from the router using SNMP.

The alternative that doesn't involve the router at all would be to run tcpdump (or some thing like that) and trigger an event on DHCP requests.

Thanks boris for your insight.

Well I will try looking into tcpdump and the likes.

And also let me try to add to this if it can clarify further what I need.

For instance,

I turn my PC on and it sends a DHCP request,

The router gets the MAC and assigns an IP address,

From here I would like the router to start a program or open a browser by pinging to the machine or starting a cron or something. Like the chrome browser stores your browsing habits what if the router could recognize your MAC and start a set of programs on boot. That is what I thought of initially.

I know the router does have flash memory which has limited writes but again just wanted to know if we could start these processes via just the communication protocols.

Could you critique on this.

Link to comment
Share on other sites

Just to throw this in there, I have seen routers which can actually write to syslog. See if your supports this feature. You will have to have a linux box for that and give the router the ip address for the linux box. This should log all info to your linux box from where you can extract DHCP information using scripts. Check your router if it supports this scenario. :)

Link to comment
Share on other sites

  • 2 weeks later...

i think i miss understood , your looking to boot your pc and at the point of it being assigned an ip address that same device is going to start a program running on that PC that was just allocated the lease, well for a start your going to need a program that is going to accept requests running on the pc just allocated the lease, the router will need a cronjob every 1 min or so to check its dhcp allocations if it contains xx:xx:xx:xx mac address then do something else die.

i would think for pure lab testing good old netcat might do this, one on your booted pc set to auto start and the other on the router configured as part of the cronjob, the test - i would use something like calc on windows, if you netcat from one device to another to get a cmd prompt then you can just run calc from the remote pc and it will fire up calc on the desktop for the current user.

still the question is why but thats what i would do for the lab steps anyway, if it produces the required results then i would look at hardening the setup by building an app thats abit more secure.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...