Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Whats the best way to find out whether I'm in my home network?



On Wed, Oct 24, 2007 at 05:45:58PM -0300, Joshua B. wrote:
> I'm trying to write a script that I can run on my notebook whether at
> home behind my router, away from home on a public network, or offline
> and have it respond differently in each case.  Specifically if I'm at
> home I want it to rsync to the server at 192.168.0.3 (or similar), but
> if I'm away from home have it rsync to mydomain.org and if I'm offline
> to do something else.

1. Check whether a default route exist;
   if not, assume you are offline and stop here.
2. Get the MAC address of your default router ('arp' is your friend
   here).  Compare it against the well-known home router MAC address.
   If they match, you are home.  Otherwise, you are in an Internet cafe.

Cheers,
 David
-- 
 David Santinoli
 Tieffe Sistemi S.r.l.                      viale Piceno 21, Milano
 www.tieffesistemi.com                         tel. +39 02 45490882


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links