Resolving a hostname from the DI-624 DHCP

Its an edit of the getIp script I wrote earlier.. this time it checks the DHCP page. Provide a hostname & it ll return you the IP (if its in there..)

# Variables
## Host

## Location & filename for temporary files

## Webpage with IP info page

## Do not edit beyond this point 😉

if [[ $map == “” || $map == “/” || $file == “” ]]
echo “Thank god I didnt trust you to fill these out wisely.”
echo ” (dont get over confident tough, this is an EXTREMELY basic test!!)”
echo “At least One of the following errors was found!”
echo “* the map and file variable can NOT be empty!”
echo “* the map can NOT be / (the root).”
echo “Since we re doing rm -f, these settings might cost you your OS!”
echo ” ;)”
echo $map$file
exit 1

# make sure there s no files that could screw the process 😉
rm $map$file* -f

# Get IP
wget -q –user $IPu –password $IPp $IPpage -O $map$file.router

# check for file existance
if [[ -e $map$file.router ]]
grep $host $map$file.router | grep dDat | grep -oE [0-9]+.[0-9]+.[0-9]+.[0-9]+ > $map$file

cat $map$file


# remove residual files
rm $map$file* -f

I needed this to have synergy connect to the right dynamic IP.. It still wont work all of the time, but at least, now it ll work more!

Next up is a script to check that page & fill in the /etc/hosts file for my linux boxes.. I might make it more secure then, since it can at this time be abused since it uses temp files..

Published by Gert


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: