I using a USB wifi dongle to connect to the Internet. When the wireless connection dies, I lose some iproute rules too.
How can I reset these rules when the interface connected again?
If you have ifupdown
(most likely if you are using Debian or a Debian-based distro) look at 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.
So in /etc/network/interfaces
you can have something like
auto eth0
iface eth0 inet dhcp
post-up /usr/local/sbin/my-custom-script
Replace eth0 for your actual interface.