Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 == "" {++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

Your Answer


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.