05 Dec

Script to keep track of IP address of machine

Just now realized that I have over few thousand files in “Latest IP” directory. This is result of poor workaround I created sometimes back to keep track of IP address.

 

To fix it, I wrote a quick shell script and good enough – it works! 🙂

Prime purpose of this script is to write latest IP address along with date/time stamp. Thus, one can simply call this script from cron job to keep track of IP address usage.

Here’s few line code of the script:

#!/bin/bash

Quick script to grab latest IP address

ip=$(curl http://www.dnsmadeeasy.com/myip.jsp)

date=$(date)

print=$(echo IP address is $ip at $date)

echo $print >> /OUTPUT-LOCATION/ip_log.txt 

Thanks to DNSMadeEasy for http://www.dnsmadeeasy.com/myip.jsp which provides latest external/public IP address in simple text form.

 

You can download direct script file from here and can call it as required.

Leave a Reply