On CentOS, network interface related scripts are found in /etc/sysconfig/network-scripts. Among them is ifup-post which is supposed to be 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
The code snippet means that if there exists a script called ifup-local in /sbin, the script gets executed with an interface name argument. On vanilla CentOS system, no such script exists. So in order to run a startup script automatically after a network interface is up, create an executable script /sbin/ifup-local, and put in there any command or script you want to run. For example:
$ sudo vi /sbin/ifup-local
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”
$ sudo chmod +x /sbin/ifup-local
- You must login to post comments
Please login first to submit.