连接接口后执行自定义脚本


9

我使用USB wifi加密狗连接到Internet。无线连接中断时,我也会丢失一些iproute规则。

再次连接接口后,如何重置这些规则?


1
看一下udev
terdon

Answers:


14

如果有ifupdown(很可能在使用Debian或基于Debian的发行版),请查看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.

所以/etc/network/interfaces你可以有类似

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

将eth0替换为您的实际接口。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.