Mailinglist Archive: opensuse (2441 mails)
| < Previous | Next > |
Re: [SLE] automaticaly send an IP change
- From: Brad Bendily <brad@xxxxxxxx>
- Date: Tue, 14 Jun 2005 10:57:41 -0500 (CDT)
- Message-id: <Pine.LNX.4.44.0506141047560.11290-100000@xxxxxxxxxxxxxxx>
> > Is there a script/package which can check the external IP on regular
> > basis and send the changes to an email?
>
> Is the host name consistent? If so, you can just do a dns lookup. If
> the host name changes with the IP, then that won't work. Another
> possibility, is a dynamic dns server, which many firewall/routes can be
> configured to use.
Here's a script that I made that at first I ran every 12 hours at my
house. Until I made the script below that runs hourly.
Also worth noting is that this stuff is running on RedHat 7.x
#!/bin/sh
FILE2=`echo "/fwlog/ifconfig.txt"`
touch /fwlog/ifconfig.txt
ifconfig eth0 | grep inet | awk -F: '{print $2}' | sed 's/Bcast//' > /fwlog/ifconfig.txt
mv -f /fwlog/ifconfig.txt $FILE2
cat $FILE2 | mail -s"IP address, ifconfig" email@xxxxxxxxx
I have another script that checks the ip and only sends an email if it's
changed. This may be better for you. This runs hourly.
#!/bin/sh
ifconfig eth0 | grep inet | awk -F: '{print $2}' | sed 's/Bcast//' >
/etc/fw/ipcheck
I=`cat /etc/fw/ip`
#IP2=`cat /etc/fw/ipcheck`
P=`cat /etc/fw/ipcheck`
#echo "My ip is $IP1"
#echo "My ip is $IP2"
if [ "$I" != "$P" ]; then
/etc/./ipshow
/etc/fw/./fw
rm -rf /etc/fw/ip
cp /etc/fw/ipcheck /etc/fw/ip
#echo "My ip is $I"
#echo "My ip is $P"
#else
#exit 0
fi
| < Previous | Next > |