Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to use a Foxboard a simple network monitor for multiple routers (all routers are connected to the internet). Foxboard is a mini pc with an embedded version of Debian.

My idea is to use multiple virtual network devices like this:

  • eth0
  • eth0:1
  • eth0:2

I found a nice Python script to ping an external host here (the solution from Ryan Cox):

Is it possible to configure Debian to use eth0 when I ping and eth0:1 when I ping

share|improve this question

2 Answers 2

up vote 4 down vote accepted

That depends on what IP addresses the various sites are on, but in general this is doable through use of static routes. You configure the static routes on Debian through the /etc/network/routes file.

One caveat: if the sites are all Virtual Hosts on the same IP address you won't be able to do it.

# Destination  Gateway           Netmask              Interface      eth0      eth0.1
share|improve this answer
Exactly what I needed, thanks! – het.oosten Sep 2 '12 at 12:56

Here is the complete script, perhaps it can be useful for anybody who is looking for a cheap and low energy network monitor (thanks to Ryan Cox, see topic start). I think it will also run on a Raspberry board.

I made a cronjob to run this script every 5 minutes.

Remember to set a route for the smtp servers as well, otherwise the mail message won't reach you :-)

from threading import Thread
import subprocess
from Queue import Queue

num_threads = 4
queue = Queue()
ips = ["","","",""]
modem = ["modem1 - entrance - network","modem2 - basement - network","modem3 - office - network", "modem4 - office2 - network"]
#wraps system ping command
def mail_error(ip):
    password = False
    if ip == "" or "":
        smtp_host = "smtphost1"
        poort = 25
        smtp_host = "smtphost2"
        poort = 587
        password = True
    import smtplib

    from email.mime.text import MIMEText
    text = "Network error ip address %s" % modem[ips.index(ip)]
    msg = MIMEText(text)
    msg['Subject'] = 'Network wrror %s' % modem[ips.index(ip)]
    me = "mymailaddress"
    you = "mymailaddress"
    msg['From'] = me
    msg['To'] = you
    s = smtplib.SMTP(smtp_host,poort)
    if password:
        s.login("username", "pass")
    s.sendmail(me, [you], msg.as_string())

def pinger(i, q):
    """Pings subnet"""
    while True:
        ip = q.get()
        print "Thread %s: Pinging %s" % (i, ip)
        ret ="ping -c 1 %s" % ip,
                        stdout=open('/dev/null', 'w'),
        if ret == 0:
            print "%s: is alive" % ip
            print "%s: did not respond" % ip
#Spawn thread pool
for i in range(num_threads):

    worker = Thread(target=pinger, args=(i, queue))
#Place work in queue
for ip in ips:
#Wait until worker threads are done to exit    
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.