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

[FWP] Perl Fixes My Network (Cable Modem)



Occasionally my cable modem connection drops. This happens every week
or so. Sometimes a few times a week, sometimes not. Often times I'm
not home when it does--I'm at work wondering why I can ping home.

The only solution is to turn the cable modem off and back on. Yes, I
have to occasionally reboot the cable modem. It very well could have
Windows running inside.

My network looks something like this:


    Cable <----> Firewall <----> Ethernet Switch
                 (pizza)               |
                                       |
                            peach <----+
                            billg <----+
                        thinkpad0 <----+


When this first started happening, I wrote a little ping daemon of
sorts (in Perl using Net::Ping). It simply runs on my firewall and
attempts to ping my default gateway into the @home network. It notes
that the ping was ok or not ok and then waits for a fixed amount of
time (usually 60 seconds) and repeats the process. This gives me a log
of when my connection dies.

The ping daemon has to run on the firewall (as opposed to any other
machine) to eliminate the possibility that I've dome something like
kick the power connector for the ethernet switch out of the wall. (It
has happened more than once.)

But it doesn't fix the problem. It just logs the problem. I have to
come home and reboot the cable modem. Clearly this is not a good
situation.

It turns out that stuck in the back of one of peach's serial ports is
one of those firecracker X10 controllers. I use X10 to control the
lights and fans in my apartment. I even wrote a Perl wrapper (called
`x10') which knows the human readable names off all my devices (from
my ~/.x10 file), such as "ComputerFan", "LivingRoomLight", "BedLight"
and so on.

With a couple lines in cron I have a pretty automatic apartment when
it comes to lighting and air circulation.

Then I had an idea. Why don't I just plug the cable modem into an X10
appliance module. Then I can reboot it whenever I want. Great. So I
did.

But that's not enough. I still have to be at home to fix the
problem... Unless the ping daemon (known as PingCheck from now on) was
able to somehow reset the cable modem.

Since the X10 stuff isn't on the firewall, I just wrote a companion
daemon (called x10d) which runs on peach and accepts X10 commands over
the network. Then I modified PingCheck (running on the firewall) to
contact x10d and power-cycle the cable modem when there is a problem.

You can do very handy stuff in 100 lines of Perl code. :-)

Problem solved (or at least worked around).

Jeremy
-- 
Jeremy D. Zawodny                Web Geek, Perl Hacker, Yahoo!
http://www.wcnet.org/~jzawodn/   Jeremy@Zawodny.com

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe