Execute script personalizado quando uma interface for conectada

Execute script personalizado quando uma interface for conectada

Estou usando um dongle wifi USB para me conectar à Internet. Quando a conexão sem fio termina, também perco algumas regras do iproute.

Como posso redefinir essas regras quando a interface for conectada novamente?

Responder1

Se você tiver ifupdown(provavelmente se estiver usando Debian ou uma distribuição baseada em Debian), veja man interfaces:

   post-up command
          Run command after bringing the interface up.  If this command fails then ifup aborts, refraining from marking the interface as  con‐
          figured  (even though it has really been configured), prints an error message, and exits with status 0.  This behavior may change in
          the future.

Então /etc/network/interfacesvocê pode ter algo como

auto eth0
    iface eth0 inet dhcp
    post-up /usr/local/sbin/my-custom-script

Substitua eth0 pela sua interface real.

informação relacionada