
我使用 USB wifi 適配器連接到互聯網。當無線連線中斷時,我也會遺失一些 iproute 規則。
當介面再次連接時如何重置這些規則?
答案1
如果您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 替換為您的實際介面。