0
0
  • You must to post comments
0
0

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.

#!/bin/sh
if [ -x /sbin/ifup-local ]; then
/sbin/ifup-local ${DEVICE}

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

#!/bin/sh
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

$ sudo chmod +x /sbin/ifup-local

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.