Re: host name help
- From: Bit Twister <BitTwister@xxxxxxxxxxxxxxxx>
- Date: Tue, 25 Apr 2006 21:03:29 -0500
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.
.
- References:
- host name help
- From: dnoyeB
- Re: host name help
- From: Bit Twister
- Re: host name help
- From: dnoyeB
- Re: host name help
- From: Bit Twister
- Re: host name help
- From: dnoyeB
- Re: host name help
- From: Bit Twister
- Re: host name help
- From: dnoyeB
- Re: host name help
- From: Bit Twister
- Re: host name help
- From: dnoyeB
- host name help
- Prev by Date: Re: host name help
- Next by Date: Re: tracking down lock ups in fedora
- Previous by thread: Re: host name help
- Next by thread: Re: host name help
- Index(es):
Relevant Pages
|
|