Are all scripts in /etc/network/if-up.d run when a network interface is brought up?

If so, what is the post-up command for in the interfaces file?

  • 1
    All ".d" folders contents, conventionally, is executed. Some of them actually need ".sh" filename extension. All of the files should be executable. – kolypto Nov 6 '09 at 15:36

Yes generally any script that is marked as executable and placed in that folder is ran. The files do have are limited to a specific set of names because run-parts is used.

The post-up does the same thing as using up. Placing a script in the if-up.d is the same as simply using a post-up that points to a script or command somewhere else. Usually you would use the up|post-up when you just needed to run a single command for a single interface. When you have something more complex you would create a script.

man interfaces

up command

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.
There  exists  for  each  of  the  above  mentioned options a directory
/etc/network/if-<option>.d/ the scripts in which are run (with no argu-
ments) using run-parts(8) after the option itself has been processed.

man run-parts

run-parts  runs  all  the  executable  files  named  within constraints
described below,

If  the  --lsbsysinit  option  is not given then the names must consist
  • 1
    So if you want a script being run only after the interface is up and it needs stuff in the if-up.d folder to be ready, you either have to name it so it will fall in lexical order after the command you need to operate, or put into another directory and run via the post-up command. Does that sound right? – Spig Nov 4 '09 at 22:17
  • 1
    Yes, I believe so. – Zoredache Nov 4 '09 at 22:22
  • Such a nice detailed answer. Even 10 years later, still providing insight. – Xofo May 9 at 22:57

Your Answer

