VMotion logo
Please Login or Register
SALES: +353 61 503060 | sales@vmotionhost.com
SUPPORT: +353 61 503061 | support@vmotionhost.com

Portal Home > Knowledgebase > Guides > Operating Systems > CentOS > CentOS: Start custom script automatically after network startup


CentOS: Start custom script automatically after network startup




Find the ifup-post under /etc/sysconfig/network-scripts. This scipt is called right after any network interface is brought up online. In this script, you will find the following code snippet toward the end.
if [ -x /sbin/ifup-local ]; then
    /sbin/ifup-local ${DEVICE}


In the code snippet above, if ifup-local script exists in /sbin location, then script gets executed with an interface name in argument. Usually no such ecript like ifup-local exists so in order to run a startup script automatically after a network interface is up. Create an executable script called ifup-local in /sbin and put in there any command or script you wish to run.

Here is an example:

if [[ "$1" == "eth0" ]]
then
  echo "this part will be executed right after eth0 is up."
  echo "so you can put any startup command for eth0 here"
else
  #DO_NOTHING
fi


when script is done, use command to get the script executable.


$ sudo chmod +x /sbin/ifup-local


Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read


Funded by the European Globalisation Fund TRUSTe Privacy Policy
VMotion IT Solutions LTD®, registration number 489707, VAT number IE 9772534C. Copyright © 2010-2017 VMotion IT Solutions
Funded by the European Globalisation Fund