Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to reliably detect whether or not a machine is multi-homed? I'd like to be able to write a script that will return a true or false regarding that information.

share|improve this question
    
How are you defining multi-homed? Multiple up-stream links, multiple network interfaces, multiple IP addresses? Having ip_forwarding enabled? en.wikipedia.org/wiki/Multihoming#Multihoming_variants –  Zoredache Nov 9 '11 at 2:24
    
Ideally, all of those situations should be detected, though I don't need to identify which one is present. I realize this may not be a trivial task, but I'm researching my options at this point. –  noisesolo Nov 9 '11 at 19:22
add comment

1 Answer

up vote 1 down vote accepted

You can approximate the definition of a multihomed machine as one having two default routes. A more precise definition would require determining how independent the routes are, which does seem daunting.

route -n | awk '$1 == "0.0.0.0" {++r} END {exit(r<2)}'
route -n --inet6 | awl '$1 == "::/0" {++r} END {exit(r<2)}'

(The Solaris calls may require tweaking.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.