tags 355756 + patch thanks Thank you for the suggestions. I'll check for the ip command and if available, select the first solution, if not check for route and if not that then default to the current one.
Thanks a lot. Regards, // Ola On Wed, May 31, 2006 at 11:52:03PM +0200, Sven Mueller wrote: > 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 -- --------------------- Ola Lundqvist --------------------------- / [EMAIL PROTECTED] Annebergsslingan 37 \ | [EMAIL PROTECTED] 654 65 KARLSTAD | | +46 (0)54-10 14 30 +46 (0)70-332 1551 | | http://www.opal.dhs.org UIN/icq: 4912500 | \ gpg/f.p.: 7090 A92B 18FE 7994 0C36 4FE4 18A1 B1CF 0FE5 3DD9 / --------------------------------------------------------------- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]