Hi. Here is a script snippet which detects the interface containing the default route. I would guess that this is usually the interface the user will want to monitor.
DEFAULTDEV="`ip route | grep default | \ sed -e 's/.*dev //;s/ *src.*//' | \ sort -u`" Perhaps this helps further improving on this issue. The above requires the iproute package to be installed. An alternative using net-tools would look like this: DEFAULTDEV="`route -n | grep -E '0.0.0.0 *[0-9.]* *0.0.0.0' | \ awk '{print $8;}'`" Unfortunately, there are setups which carry multiple default routes (and those setups can work). In these setups, the iproute version above returns multiple device entries seperated by spaces. The net-tools version might fail in those setups (multiple default routes can only be set with the iproute 'ip' tool), I don't know. However, the iproute version should return usable default values in most setups, as long as a single default route exists. If there is no default route, it will simply return an empty string, which could lead to further tests. Regards, Sven
signature.asc
Description: OpenPGP digital signature