[Techtalk] bash question

gossamer axe gsmraxe at gmail.com
Wed Oct 18 01:32:29 UTC 2006


I'm not sure if this is ok to post this here...But I have a bash question...

My ISP (pacbell) is great for going down, I seem to lose something with the
name server.  I can get to the internet, but typing host
www.google.comdies.  I run a dynamic name on my server and I seem to
be forever losing
it.  I've tried several rewrites of scripts to fix this...but I can't seem
to get my name server back up...

This is the script I've been fussing with for a while now:  dnstest2.sh  I
also run these in crontab */5 minutes

#!/bin/sh

RMM="/sbin/rmmod"
MDP="/sbin/modprobe"
START="/usr/sbin/adsl-start"
STOP="/usr/sbin/adsl-stop"

EXTIF="ppp0"
EXTIP="`/sbin/ifconfig $EXTIF | grep 'inet addr' | awk '{print $2}' | sed -e
's/.*://'`"
HOSTIP="`/usr/bin/host gypsy.sytes.net | awk '{print $4}'`"

if [ "$EXTIP" != "$HOSTIP" ]; then

   /usr/sbin/adsl-stop
   NPID="`ps aux | grep noip2 | grep nobody | awk '{ print $2 }'`"
   /usr/local/bin/noip2 -K "$NPID"

   /usr/sbin/adsl-start
   /etc/rc.d/rc.firewall
   /usr/local/bin/noip2
   /usr/local/bin/dynubasic.sh
fi
exit 0

So, basically, I try to see if I can host "gypsy.sytes.net" and if I can't
stop everything and re run it.  I also used to unload the network module and
modprobe for it again, but that seemed like overkill.  The first 4 variables
are leftover from earlier scripts.  They do nothing now.

This next one I just wrote 10 minutes ago, I tested it and it seems ok...I'm
not sure if it will work 100% of the time

#!/bin/sh

IMUP="`host www.google.com`"

if [ -n "$IMUP" ]; then

   /usr/sbin/adsl-stop
   NPID="`ps aux | grep noip2 | grep nobody | awk '{ print $2 }'`"
   /usr/local/bin/noip2 -K "$NPID"

   /usr/sbin/adsl-start
   /etc/rc.d/rc.firewall
   /usr/local/bin/noip2
   /usr/local/bin/dynubasic.sh
fi
exit 0

The NPID is to kill noip2 daemon which is supposed to listen for changes in
my IP# and get the new one for gypsy, doesn't seem to work too well tho =D
So now, just see if I can host google, if it's not able to get to it,
restart everything.  Does anyone else have any ideas?  I'd like to be able
to ssh to my machine and work on my website from work, but I'm unable to
most of the time.  I also can't figure out why I can't host something but I
can get out to the internet and use firefox to go to www.google.com but I
can't access my machine.  I don't want to email my ip# to myself either...I
just wanted something easy (but I know it's not working out to be) so I can
access my machine from anywhere.

thank you!


-- 
Gossamer Axe
gsmraxe at gmail.com
http://gypsy.sytes.net/


More information about the Techtalk mailing list