scripts, concepts, and bewilderments from ddgenius



DHCP Alert - Linux

Ever lost your [dhcp-connected] Linux/Unix box in networkland because you had to reboot the thing remotely? If not, you're lucky, because I have this problem all the time. This dandy little C/PHP tool will help keep track of your machine, and emails you whenever the ip address changes.
Requires:
File Breakdown
ipaddress.old - contains ip address to be referenced against new address
- goes in /usr/local/etc
ipquery - PHP wrapper for get_ip (C script)
- emails admins when ip changes
- goes in /usr/local/bin
get_ip.c - Source for get_ip (code snippet from SourceForge.net)
- Compiled C script for querying ip goes in /usr/local/bin
README - All this same info


Download: dhcp_alert.gz v0.2(12k)


Based on your version of *nix, you may have to recompile get_ip.c (built on Redhat 6.x - 7.x)

Instructions:
1. If necessary, recompile get_ip.c to get_ip
2. Copy get_ip to /usr/local/bin
3. Copy ipaddress.old to /usr/local/etc
4. Modify a few lines in "ipquery", based on your needs/wants/configuration. Location of php is important in first line...
5. Run ipquery a few times to test -- first time should update ipaddress.old and send you email.
6. Copy ipquery to /usr/local/bin
7. Setup the ipquery script to run either at boot (rc.local), or as a cron job (crontab -e).
**I have mine running as a cron every half hour, because my DSL tends to go down once in awhile, which causes it to grab a new one without rebooting. Stupid ISP.

**I recently set this up to utilize the following script for updating dynamic DNS records on dhs.org:
http://www.kublai.com/~cromwell/happycamper/
Now you can use DHCP Alert to check for a different IP address and fire off the above perl script (modified to work with your eth0) to update a dynamic DNS entry. So your permanent address on the net could be something like frankendev.2y.net.



DHCP Alert - Win32

I've ported the concepts from the Linux version over for Win32 users. The following is the README.txt:
DHCP Alert v0.1 - Win32

Keeps track of DHCP IP Address and notifies user of change via email.

*Note: Works well with *single nic* machines.  Multi-nic machines may
       or may not work...

FEATURES:
- Supports Windows 9x, NT, 2000.
- Utilizes mailto v1.6 (freeware) for sending email alerts. Thanks
  to jscottb@infoave.com.
- Supports ability to run other applications upon change of IP Address
  (Such as Dynamic DNS services like dhs.org)

INSTALLATION (very simple):
1. Move the created directory to the desired location
   (perhaps C:\Program Files\dhcp_alert) after extracting the main
   file (dhcp_alert-0.x.zip).
2. Modify the mailto.cfg file with the appropriate settings.
3. Schedule the dhcp_alert.bat file in the respective OS.
   - For NT/2000, use the 'at' command.
   - For 9x, use the "Task Scheduler".

NOTES:
1. The mailto.zip file was included for convenience - it does not need to
   be extracted to execute DHCP Alert.
2. The first execution of DHCP Alert creates a file called 'ipaddr.old'
   which contains a static address (compared to current address for
   checks).  This file will be utilized by the program from then on.

Questions/comments/complaints can be sent to doubledomegenius at aol dot com.

Download: dhcp_alert_0.1.zip (70k)



Crontab Enumeration

Here's a little script to enumerate the contents of a specific user's cron, written in...you guessed it...PHP. You need to rename this and make it executable. I use it as part of a larger script for auditing.


Other Stuff in the Works:

Node Runner is a PHP application designed to contact nodes in a specific order based on the description of the node. If a node does not respond, each of it's dependencies are systematically checked until the problem is isolated.

Node Runner uses a shell script for its basic network polling, a PHP web interface for node information, reports, etc., and a MySQL database for a backbone.



phpCrontab will serve as a tutorial for scheduling things like the Node Runner network monitor program in the cron. It demonstrates proper syntax for crontab additions and explains how to go about changing the crontab. I had originally hoped to automate this process entirely, but I don't wish to run Node Runner with any sort of superuser access, which would be required to enumerate the crontabs from any user on the machine. Perhaps someday I will go this direction, but for now, a program that requires superuser access tends to lose its appeal very quickly.

ddgenius "doubledomegenius at aol-dot-com"