Re: host name help



On Tue, 25 Apr 2006 21:43:06 -0400, dnoyeB wrote:
Bit Twister wrote:

That would be another use for the dhcpclient exit script.

set - $(tail -17 lease_fn_here | grep fixed-address)
_ip=${2%;}
mail -s "ip=$_ip" email@xxxxxxxx < /dev/null

thats the whole script? Wheres the part that gets the ip or recognizes
the change?

The _tail_ command fed the last stanza of the lease to _grep_ which picked
out the ip address line and _set_ parsed the line into $args. See breakdown

tail -17 /var/lib/dhcp/dhclient-eth0.leases | grep fixed-address
fixed-address 24.1.202.185;

set - $(echo "fixed-address 24.1.202.185;")

echo $0 $1 $2
bash fixed-address 24.1.202.185;

then I used bash substring function to rip off ; from arg $2


of course if it sees a change and sends an email, its easy
enough to read the addy of the mail server. So this script is run
automatically when the ip changes?

Yes, when dhcpclient is finishing up, it checks for and runs whatever
you put in /etc/dhclient-exit-hooks.


just wondering how it knows the ip
changed or if thats part of the os.

Dhcp clients are given a lease time. Half way through the lease time
it asks the dhcp server to renew the lease. Server sends back the
lease info and the client acts on the contents.

mine is like this

THEIPTEXT=$(snmpwalk -v1 -Oqsv -c public 192.168.0.1 IP-MIB::ipAdEntAddr
| egrep -v "192.168|0.0")

which has to keep checking in order to see a change. Oh, i forgot to
mention that its my external router that changes IP, not the IP of the
linux box :)

Hmm, the devil is in the details. 8-)

I also find it handy for the script to check for short lease times
which indicate they are doing something on my network segment.
Also I use wget http://192.168.100.1
to fetch the cable modem status pages to check signal levels.
.



Relevant Pages

  • Re: Aaagh! cScript no longer Returning! ??
    ... > try turning them off and run the script again... ... thats our entry level environment that must be used as a starting ... point] I am also running this on XP SP2 machines, ... we have a script that builds the web site on install. ...
    (microsoft.public.scripting.vbscript)
  • Re: Whereis Kernel? & Why Debian "KDE" freezing?
    ... > There is no config file in. ... Thats not a Script, thats the kernel. ... your KDE is unstable. ...
    (alt.linux)
  • Re: Linux Home Server HOWTO - Open For Review
    ... I did want to add some type of monitoring here, but I found the script ... Thats a fair call.. ... simple are a hard match to start with, thats the reason I at least ... I think it would be suitable to include a package ...
    (Fedora)
  • Re: avoid script running twice
    ... transaction and have your script check for that before running its main body. ... I think thats the most hassle free way of doing it. ...
    (comp.lang.python)
  • another clamstats.pl question
    ... The same is with the html output. ... its just the year thats being shown wrong. ... is the portion of the script that I 'think' controls this: ... Registered Linux User 283774 http://counter.li.org ...
    (perl.beginners)