Index ¦ Archives ¦ Atom

How to detect IP Address Changes on Reboot

I've written a quick little script to detect ip address changes when the network is brought up. I have yet to try it out after rebooting but it works for now showing all inet interfaces.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/bin/sh

VAR=`/bin/ip -f inet addr`

/usr/sbin/sendmail -t <<MESSAGE
To: user@example.com
From: user@example.com
Subject: IP Address Change

$VAR
MESSAGE

exit

Make the contents of this file executable and I placed mine in /etc/network/if-up.d where scripts are run when a network interface is brought online.

© Steve Spigarelli. Built using Pelican. Theme by Giulio Fidente on github.