Тоже озадачился данной проблемой. Нашел данный топик, вроде все стало понятно, но до определенного времени.
Применительно к Debian, сначала читал
здесь раздел
5.14.3.3 Configuring firewall rules through ifup. Затем заглянул в man interfaces, там изучил следующее
IFACE OPTIONS
The following "command" options are available for every family and method. Each of these options can be given
multiple times in a single stanza, in which case the commands are executed in the order in which they appear in the
stanza. (You can ensure a command never fails by suffixing "|| true".)
pre-up command
Run command before bringing the interface up. If this command fails then ifup aborts, refraining from
marking the interface as configured, prints an error message, and exits with status 0. This behavior may
change in the future.
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.
down command
pre-down command
Run command before taking the interface down. If this command fails then ifdown aborts, marks the interface
as deconfigured (even though it has not really been deconfigured), and exits with status 0. This behavior
may change in the future.
post-down command
Run command after taking the interface down. If this command fails then ifdown aborts, marks the interface
as deconfigured, 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 arguments) using run-parts(8) after the option itself has been processed.
Вроде бы все предельно ясно. Но смутила последняя фраза. Я ее понял как: для каждой из вышеуказанных опций существует каталог /etc/network/if-<option>.d/ для скриптов, запускаемых (без аргументов) используя run-parts, после чего эти опции будут обработаны (выполнятся).
Что не понятно. Для того, чтобы некий скрипт, в данном случае iptables, выполнялся, скажем перед поднятием интерфеса, мне необходимо:
a. положить этот скрипт в каталог /etc/network/if-pre-up.d;
b. положить этот скрипт в каталог /etc/network/if-pre-up.d и прописать в файле interfaces опцию pre-up $name_script;
c. положить скрипт куда угодно (например в /etc) и прописать его в interfaces pre-up /path-to-file/$name_script.
Сам больше склоняюсь ко второму варианту, но не уверен до конца.