Does Fedora support something similar to the post-up command (as in Ubuntu) or does it have any other alternative for this command?

I want to run a custom script after activating network interface but I have no idea how to manage that in Fedora.

post-up command

         Run command after bringing the interface up.   If  this  command
         fails then ifup aborts, refraining from marking the interface as
         configured (even though it has really been  configured),  prints
         an  error  message,  and exits with status 0.  This behavior may
         change in the future.
  • I suspect you'll have to do something using either Systemd or NetworkManager to get this functionality. askubuntu.com/questions/13963/….
    – slm
    Commented Jun 14, 2015 at 1:08

1 Answer 1


One idea would be to put a script in this directory: /etc/NetworkManager/dispatcher.d. NetworkManager will run scripts in alphabetical order when various network events occur.

excerpt: from the man page:

NetworkManager will execute scripts in the /etc/NetworkManager/dispatcher.d directory in alphabetical order in response to network events. Each script should be (a) a regular file, (b) owned by root, (c) not writable by group or other, (d) not set-uid, (e) and executable by the owner. Each script receives two arguments, the first being the interface name of the device just activated, and second an action.

Based on the man page there's the following "events": up, down, vpn-up, vpn-down, hostname, dhcp4-change, & dhcp6-change.

I suspect that you could do what you want using the "up" event. This blog post, titled: "Use NetworkManager to Launch Scripts Based on Network Location", shows how you could construct a shell script to run when an interface, (eth0), goes up.

For example (code "borrowed" from that blog post):


wait_for_process() {
  PID=`/usr/bin/pgrep $PNAME`
  while [ -z "$PID" ]; do
        sleep 3;
        PID=`/usr/bin/pgrep $PNAME`

start_synergy() {
     wait_for_process nm-applet
     /bin/su $USER -c "/usr/bin/synergyc $1"

if [ "$IF" = "eth0" ] && [ "$STATUS" = "up" ]; then

        #LAN Subnet at work
        if [ -n "`/sbin/ip addr show $IF to $NETMASK`" ]; then
                start_synergy $ARGS
                exit $?


This example should be enough to get you started in doing what you're trying to do.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .