Forum: 

Run a script when IP address changes

Adrian Moya's picture

Guys, do you know any method to run a script when there is a system IP address change? I would like to know a good method for another TKLPatch I'm preparing. It could be usefull maybe if confconsole had some hooks on this event to plug in users script. 

Thanks for your support. I'll continue searching google ;)

Alon Swartz's picture

I'm not exactly sure what you want to do, but here are some pointers that might help:

/etc/network/{if-down.d, if-post-down.d, if-pre-up.d, if-up.d}

If what you want is dhcp specific, you might be interested in /etc/udhcpc/* (but I'm not sure I would recommend this direction as you never know if a user, or TurnKey will change the dhcp client).

I hope the above helps.

Adrian Moya's picture

I've made some tests with the script in if-up.d and if-pre-up.d but have no success. Can't find the official documentation for those to see what I'm doing wrong. That's why I asked. wait... I think I know what happened!!! It could be an 8th layer error... let me check! 

popular's picture

How about constantly running a script in background to check for current ip address using ifconfig?

 

while [ 1 ]; do

ifconfig | grep "inet"

## process above output

sleep 5;

Post new comment