Run script when eth0 UP

天大地大妈咪最大 提交于 2021-01-29 05:00:46

问题


I need to run a script after the start eth0 interface in Centos 6.8

When I do it with ppp0 I put scripts here: /etc/ppp/ip-up.local and it works. How to do the same with eth0?

I tried to put scripts in difference files, checking permissions, but does not work.

Files that I tried to put scripts:

**/etc/sysconfig/network-scripts/ip-up.local
/etc/sysconfig/network-scripts/ifup-local
/sbin/ifup-pre-local
/sbin/ifup-local
/sbin/ip-up.local**

回答1:


Using NetworkManager, we can create a file /etc/NetworkManager/dispatcher.d/15-my-ip-up-local that will run the necessary scripts

#!/bin/bash
### /bin/bash /etc/NetworkManager/dispatcher.d/15-my-ip-up-local

if [ "$1" = "eth0" ] && [ "$2" = "up" ]; then
echo run my scripts in up
else
echo DO_NOTHING
fi


来源:https://stackoverflow.com/questions/38523734/run-script-when-eth0-up

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!