If anyone's interested, these recipes and script seems to work well. The
mail file must be sent from root (in my case by ip-up.local) to root (for
named restart permission), have the Subject: line containing "inetfeeler
PPP up", and should be generated by ifconfig for the parsing to work... If
you're worried about someone falsifying an e-mail, then passwords or codes
could be used - but I'm not presently.
These are the recipes for /root/.procmailrc :
--------------------
# This recipe grabs DOMAINNAME and IPNUMBER for dnsupdater
# and forwards that info if the domain is listed
:0
* ^Subject:.inetfeeler.*PPP.up
{
DOMAINNAME=`grep "From: root" | sed "s/^.*@//;s/>//"`
IPNUMBER=`grep "P-t-P" | sed "s/^.*inet addr://;s/\ .*//"`
:0 i
* $DOMAINNAME ?? domain.com
| /root/dnsupdater $DOMAINNAME $IPNUMBER
# Repeat as needed for other "dynamic" domains
:0 i
* $DOMAINNAME ?? ANOTHERDOMAIN.COM
| /root/dnsupdater $DOMAINNAME $IPNUMBER
# For any non-listed domains...
:0 i
/dev/null
}
--------------------
Here's the dnsupdater script (a little inefficient in sed usage, I know)
--------------------
#!/bin/sh
IPNUMBER=$2
SYSTEMNAME=`echo $1 | sed "s/\([^\.]*\)\.\([^\.]*\)\.\([^\.]*\)/\1/"`
DOMAINNAME=`echo $1 | sed "s/\([^\.]*\)\.\([^\.]*\)\.\([^\.]*\)/\2\.\3/"`
cat /var/named/$DOMAINNAME | \
sed "s/\(^$SYSTEMNAME.*IN.*A\).*/\1 $IPNUMBER/" \
> $DOMAINNAME.new
mv -f $DOMAINNAME.new /var/named/$DOMAINNAME
/etc/rc.d/init.d/named restart
---------------------
Lee Howard
At 06:06 PM 8/4/00 -0500, David W. Tamkin wrote:
Lee Howard asked,
| I have a linux system that is connected to the internet via a dial-up
| connection and receives a dynamically assigned IP number. Each time it
| connects a script e-mails me the P-t-P line from ifconfig so that I can
| know its IP number.
|
| Is there a way that I can utilize this e-mail to adjust the domain file and
| restart named? The dialup connection stays up for several days at a time,
| and it's nice to connect to it by name rather than looking up the IP number
| each time. So far I've been doing the domain updating by hand.
If there's a predictable place in the message where procmail can find the new
information, and there's a program or script that procmail can invoke which
can do the updating, yes.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail