running script when detecting access to net

running script when detecting access to net

Post by Michael B. Alle » Fri, 25 Aug 2000 04:00:00


Is there a daemon that can watch the tcp traffic on the local machine and
run an arbitrary script if specific subnets or addresses are requested? Such
a daemon might have a config file that looks like routing table entries but
with a destination, genmask, script to run, and lock file.    null
/some/file/that/always/exists    /etc/ppp/ppp-on-work
/var/run/ppp-on-work.lock        /etc/ppp/ppp-on         /var/run/ppp-on.lock

So if I launch Netscape and try to access a site like dns
will see a zone file for '' and decide to query my dns server at
work which will no doubt begin with 172.17 and therefore trigger pppd to
dial work(actually I don't know for sure if zone files work this way, I'm
making this up as I go along :~). If I try to access, my machine
will not recognize the domain and try to query my isp's dns server which
would match the default entry of and dial my isp. If the daemon runs
a script it creates a lock file so it knows to stop listening.

Get it? Can I do this?

I'm starting to get pretty good at c but I haven't done any sockets
programming with it. How hard could it be to write such a 'netdetectd'
daemon? I would think this might be a pretty useful little utility. Any