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
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" ]]
echo "this part will be executed right after eth0 is up."
echo "so you can put any startup command for eth0 here"
when script is done, use command to get the script executable.
$ sudo chmod +x /sbin/ifup-local
Add to Favourites Print this Article