Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Networking Code

by vroom (Pope)
on May 26, 2000 at 01:30 UTC ( #14876=sourcecodesection: print w/replies, xml ) Need Help??
SOCKS4 Server in Perl
on Jul 01, 2002 at 18:21 UTC
by strredwolf
Something I grew frustrated with, so I wrote up my own Socks 4 server. Supports CONNECT and BIND. Probably extensible to Socks 5 (have to pull the specs on it). Quick and dirty hack.

To use, grab netpipes and use outgoingIPaddr

cvs daemon in perl
on May 10, 2002 at 18:37 UTC
by tallfred

I wrote a CVS server in perl which stores the repository in MySQL. I am working on a better access/privileges system, but some feedback would be useful.

The code has a web page interface very similar to cvsweb.

(code) HTTP connectivity log, or nail up dial connection
on Apr 23, 2002 at 01:08 UTC
by ybiC

Fetch a random web page from a list of URLs.   Waits a random length of time between fetches.

Written with two purposes in mind:
  * log internet connectivity
  * nail up analog dial connection
Mostly the latter, so my ISP won't drop my connection during looong downloads.

There are a number of commandline options+arguments.   Perhaps the more interesting are

  • --verbose=1 which reports only delta of success/fail ala zeno from Internet Connection Uptime Logger
  • --errDelay=1 to cause almost-immediate retry on fetch failure
  • --daemonize which backgrounds and disconnects so vty can be closed
  • --logging to print progress, options, and versions to file

From a Perlish perspective, this has been an exercise in rand, IO::Tee and Proc::Daemon, plus Getopt::Long bobs that I ended up not using.   I started out "use"ing Proc::Daemon, but had to copy+tweak subs from it to allow logging-to-file while daemonized.

Thanks to tye, fletch, tachyon, lemming, chmrr and others for tips and suggestions.   And as always, constructive criticism is welcome and invited.

The Veachian IRC Daemon
on Mar 29, 2002 at 23:07 UTC
by Veachian64
This is an IRC daemon I wrote out of sheer boredom in Perl. It's in the public domain, so if anyone wants to see a simplified example of an IRC server or how a server written in Perl works and use it for whatever they want, here it is. This is the latest version of the code. An archive containing all the previous versions of the code is available as a zip or a tarball. Read the README in the archive for more info.

Updated: 12/23/2002
ARP Watch
on Mar 07, 2002 at 12:16 UTC
by rob_au
This code watches for ARP requests on the ethernet address specified and sends an alert email to the network administrator in the event of a change in the hardware MAC address associated with an IP address. This was developed in part for a network traffic accountancy system in order to maintain record of machine hardware addresses and minimise the likelihood that network users could introduce foreign equipment onto the network.

It should be noted that this code was written as a proof of concept moreso than as a stand-alone piece of code. However, this code is interesting in its own right in that no external binaries are called upon for the capturing or interpretation of the ethernet ARP packets, instead relying upon the libpcap packet capturing library.

For previous nodes relating to this type of application, review (code) MAC n' IP cheese, How can I find a MAC address from aremote IP ? and MAC Address and NIC Device on Network.

ACL Tool for Cabletron/Enterasys L2 switches
on Feb 15, 2002 at 19:07 UTC
by zengargoyle

Helps manage the Access Controll List on Cabletron/Enterasys L2 switches (6000/2000). Requires SNMP, 2nd/3rd Gen switches w/ latest 2.0+ code, and the MIB's from Enterasys' web site.

I would wait until it's prettier, but with the SNMP problem it' may prove usefull to anybody with these switches.

Tips, comments, etc. more than welcome. Hope it helps somebody somewhere.

(code) UDP timeout for IO::Socket, plus Pod::Usage with Getopt::Long
on Jan 22, 2002 at 08:03 UTC
by ybiC
A localhost TCP+UDP port sccaner, intended to supplement netstat -vat, which doesn't seem to report listening UDP services.   Requires no additional modules beyond those in the base Perl. was written to aid in configuring the author's computers in a reasonably secure manner. Anyone using this software is encouraged to do so in a responsible and constructive fashion. Remember, kids, always use your powers for *good*, not evil.

From a perlish perspective, this ditty has been an introduction to IO::Socket, as well as finally getting around to applying the most excellent Pod::Usage in conjunction with Getopt::Long.

As always, comments and critique are respectfully requested (and appreciated).

Update: added a bit o'clarification to description
Just found netstat -vatu for localhost TCP *and* UDP services.   D'oh!

UDP sniffer
on Dec 20, 2001 at 07:05 UTC
by cforde
This is something I'd been thinking about doing for a while. The other day I saw Simple UDP example anyone? and decided it was time.

The way to use it is to change the first 5 variable declarations to suit, make sure the server is running, run this script (which will redirect requests to the server) and start the client. The client will think it's talking to the server and the server will think it is talking to the client. Meanwhile the script is displaying their conversation for you to see. Great for debugging UDP applications when you don't have real networking tools available. With a little tinkering you could also, uhmm, diddle with the conversation...

update: improved formatting and link

Scan C-Class for used IP-addresses
on Dec 07, 2001 at 16:23 UTC
by cab
This program scans trough a given C-Class subnet and lists the addresses that respond to ping to a file.
I used it to list the addresses on our network, so i could find unused addresses.
It's not pretty or witty, but it worked for me.
The script keeps on scanning, until interrupted. Although the replys are written only once to the file.
Use the code with option 'sort <filename>' to sort the output
It uses a sort routine suggested by tye in the QA section on sorting. (Thanks for that)
Any suggestions are welcome.
This is also my first code post, so be gentle.

(code) Dynamic DNS Update with IO::Interface (look Ma, no backticks!)
on Nov 28, 2001 at 07:38 UTC
by ybiC
One of my boxen is dial-connected nailed up using /etc/ppp/ppp_on_boot plus persist and holdoff parameters in /etc/ppp/peers/provider.   Whenever the connection is (re)established, this ditty sends the new ppp0 IP address to my dynamic DNS provider.

Not much of a Perlish exercise, but was fun to make practical use of new (to me anyways) IO::Interface.

Start dynamic DNS update:

Check ppp0 status: ACTIVE
Query host for ppp0 address: PASS
Post ppp0 IP address to DynDNS service: PASS
Check DNS propagation via name lookup: PASS
Compare resolved address to local: PASS
  nnn.nnn.nnn.nnn <=
  nnn.nnn.nnn.nnn <= ppp0

Finished dynamic DNS update
PIX Syslog Parser
on Nov 07, 2001 at 02:22 UTC
by salsa
This is actually my first PERL program. It uses File::Tail and Net::SMTP to watch your PIX firewall log for changes, evaluates the changes based on keywords and then e-mails/alpha pages on a match as well as logging the entry into a critical_log file. In addition, it evaulates the growing log size and rolls it into a date and time stamped archive when it hits a certain size. Keep in my mind, that this is my first program! if you have any questions or constructive (<--- NOTE) criticism, please feel free to e-mail me.
(code) Poor Man's TACACS - automate CatOS and IOS password resets with Net::Telnet::Cisco and Net::SNMP
on Nov 06, 2001 at 03:50 UTC
by ybiC
Automate password updates for any number of Cisco routers and Catalyst switches.   Uses Net::SNMP to detect device+code types, and Net::Telnet::Cisco to make the changes.   Old, new, and confirm password entries blanked by Term::Readkey.   Command line switches facilitated by Getopt::Long.

Is a substantial rewrite and consolidation of the now deprecated "(code)) Cisco Pass Mass - IOS (deprecated by node 123464)" and "(code)) Cisco Pass Mass - CatOS (deprecated by node 123464)".   Cleaner code.   Better error detection and handling, activity logging, and results reporting.

Commandline switches include:

 --help     print Usage() to screen
 --nochange reset pw's to original
 --ROcomm   will prompt for SNMP RO community string. Default of 'public'
 --target   accepts IPaddr, hostname or fqdn of single target
 --infile   accepts name of text file list of multiple targets.

Thanks to Petruchio for pre-post critique+comments+corrections, and to c for inspiration and example of Net::SNMP device-type detection from Pancho. Also to several monks who offered good counsel on prior efforts leading up to this project.

I'm seriously considering submitting this to Freshmeat and/or Sourceforge, so please chew it up and spit it out and let me know what's not tasty.

(code) Net::SNMP, Bandwidth, GnuPlot, PNG, PostScript, Excel
on Oct 29, 2001 at 22:26 UTC
by ybiC
Query SNMP-enabled devices for interface (in|out)put octets, ifSpeed, ifName.   Creates chart of %bandwidth vs. time in PNM, PNG, and/or PostScript formats.   Raw data in CSV, tab-delimited, and/or Excel formats.

Intended for spotchecks or periodic monitoring of individual interfaces.   Tools like MRTG, MCSview, SNMPc, CWSI do well for large number of ports.

Sample graph output temporarily on my homenode pix.   As always... critique, comments, and suggestions are welcome and appreciated.

Usage: target ifIndex iterations delay outdir

target: an IPaddress, DNS name, or FQDN.
ifIndex: SNMP parameter specifying port or interface.
iterations: how many queries you wish to run. (minimum 3, default 4)
delay: seconds to wait between iterations. (minimum 10, default 30)
outdir: destination dir for outfile. No trailing '/'. (default '.')

Example: routerC 7 600 30 MyString /datadir

From a Perlish standpoint, this has been an exercise in hashes instead of arrays, return values, constants, eval, ${var}blah, and STDOUT hot.   Is a significant rewrite of "(code)) Net::SNMP bandwidth query (deprecated by node 121950)".

P.S.   I did not copy this idea from djw's "Ethernet Utilization".   Honest, I didn't, I swear.   Hey, put that phone down!   No, wait - don't call vroom!   ;^D

Update: 2001-10-31 corrected a tyop and clarified verbage in the Description

Ethernet Utilization
on Oct 24, 2001 at 00:26 UTC
by djw
SNMP query tool for reporting interface utilization stats. Does a get_request for sysUpTime, ifInOctets, and ifOutOctets and does a utilization calculation based on the difference of two samples and interface speed. Right now its setup to run every 5 minutes for an 8am-5pm workday.

You can see a sample of the graph plotted by GD::Graph here:

Thanks, djw

If you plan on using this, you will have to check your ethernet device's MIB OID. ifInOctets and ifOutOctets are the first two items in the @oids list, the last one is system uptime which you shouldn't have to change.
on Oct 22, 2001 at 00:06 UTC
by Masem
Allows better access to the list of system services on an OS. Your OS must support sockets for this to work; this includes *nix, and rules out all Windows varients - 9x, NT, 2K (and probably XP) (thanks Arguile)

I am looking for comments and critiques on this before I submit it to CPAN, msg or email me any suggestions

Net::CIDR::Lite ?? (Merge CIDR addresses)
on Oct 16, 2001 at 22:05 UTC
by runrig
Inspired by Dominus' Challenge Problem: Merging Network Addresses, I posted a reply script which was (about 20 times) faster than the Net::CIDR solution, and thought I'd make a module out of it. Also looking for comments on whether it ought to be on CPAN, and under what name. I'd never before heard of let alone used the Socket::inet_* functions, so I couldn't have done it this way without that thread. It might be interesting to get this to work optionally with IPv6 addresses, but then you'd probably have to use some big integer library like Bit::Vector, so I'm open to suggestions on that :)

Updated with tye's recommendation.

Update: Net::CIDR::Lite has been on CPAN for awhile now and updated several times over. Consider the code on this page obsolete.

Simple WebServer Scanner
on Sep 21, 2001 at 18:07 UTC
by Asmo
This script prints out the webserver version the scanned host is running (with a simple HEAD request)
Netcat like with Blowfish
on Sep 02, 2001 at 19:16 UTC
by Anarion
I usually use netcat. I just want to send some archives encrypted, so i make this program to do it. It uses Blowfish, you need to downoad it from
Pancho(configure/archive Cisco routers)
on Aug 29, 2001 at 03:41 UTC
by c
This is still for all those netadmins out there that need to make global changes by 7am and its already past midnight.
Cisco, in all their wisdom, decided to change a group of their MIBs such that older ios versions known as 11 code are no longer supported. I had originally written Pancho for that group of old-schoolers such as myself that were still using such antiquated software as 11.2.18 from way back in November, 2000.
In the moments after watching a Robin Williams movie, I felt like giving back to the youth and thus began reworking Pancho to support not only the older MIBs, but the new ones as well. I even tricked it out to query the router to figure out which ones to use.
This code is full on unstable, considering that its only been tested against the few routers I have in the house. I think it has been one hell of a lesson on net::snmp which seems to have finally accepted me as one of its own after much coaxing and sending of flowers.

humbly -c

(code)) Net::SNMP bandwidth query (deprecated by node 121950)
on Aug 13, 2001 at 02:16 UTC
by ybiC
## deprecated by "(code) Net::SNMP, Bandwidth, GnuPlot, PNG, PostScript, Excel" ##
Periodically query SNMP-enabled devices for interface (in|out)put octets, and record results in csv and xls outfiles.

Intended for relatively short term spot-tests of individual interfaces.   Other tools like MRTG, SNMPc, and CiscoWorks do fine for large number of ports, or for ongoing monitoring.   Uses Net::SNMP instead of system call to UCD-SNMP's snmpwalk like my earlier efforts.   Mind you, snmpwalk is quite useful - I just wanted to eliminate unecessary dependancies on external libraries.

Thanks to:
tachyon, HamNRye, crazyinsomniac, tilly, lemming, and wog.
Oh yeah, and to some guy named vroom.

As always:
Comments, corrections, and criteque welcome and requested.

Most recent update:
2001-08-22   10:00   Unlink .tmp at end of run, skip Spreadsheet::WriteExcel stuff if module not installed, fix wrong %util calculation, display MBytes transferred, gracefully handle non-responsive (host|OID).

on Aug 02, 2001 at 05:23 UTC
by Rex(Wrecks)
Hey all, first post so go easy on me :) I do a lot of automation to test hardware and software, I constantly fight the proprietary logging issue in a lot of code being written by fellow Automation Daemons. Since I work with a lot of hardware, specifically network gear, I wrote this utilty that can be used on both *nix and Win32 (I usually create a standalone exe for Windows) to send messages to a Syslog daemon. I have not used Perl for that long yet so I am sure there are things you can improve on.
List TLD nameservers
on Jul 21, 2001 at 20:16 UTC
by chazzz
This script has a list of top level domains and queries the root-servers for the corresponding nameservers. It then prints the results in pretty html. Requires Net::DNS.
on Jul 19, 2001 at 22:13 UTC
by fingers
Usage: options ip { ip ip ... }
Designed to get an overview or collect statisics on switchports usage using SNMP.
-b option allows you to specify community name on the command line to allow being called in a cron job -l logs basic port usage stats to a dbm file
-r is used to read files created by -l
-v gives more detailed stats on ports that are up
-c generates a csv file, can be used in conjunction with -v
Some options are mutually exclusive. The later option takes precedence.
Perl 5.6.1
RedHat 7.1
Cisco 6509,2924XL,3508XL,3512XL,3524XL,3548XL switches
I realize it may be a little sloppy and amateur, I definately would appreciate any constructive criticism anyone has about my code.
(code) Resolve list of DNS names
on Jul 11, 2001 at 23:24 UTC
by ybiC
Feed this script a textfile list of hostnames, and it spits out CSV and XLS files of names and resolved IP addresses.   I use this ditty to confirm (or deny) in one swell foop that the DNS folks have proper IP address records for every one of the hundred+ LAN switches I support.

Tested with:

  • Net::DNS 0.12
  • Spreadsheet::WriteExcel 0.31
  • Perl 5.00503
  • Debian 2.2r3

Comments and critique are welcome and requested.

Most recent update: 2001-07-12 07:00 CDT
Corrected minor mistakes in comments and above description.
Add a bit more explanation to description above.

(code) Net::SNMP, table-ish interface stats
on May 21, 2001 at 01:50 UTC
by ybiC
Query one or more SNMP-enabled devices for network interface stats.   Written specifically for multi-interface devices like routers and LAN switches, but trivial to adapt for any table-ish SNMP response.

Accepts target device(s) from command-line, and prompts for SNMP RO community string.   Example run+output, and interesting SNMP OIDs at tail of pod.  

Output is (almost) csv.   Still researching methods for better output format. Probably better to use hash of hashes (or maybe hash references) than to munge existing output.

No external libraries needed.   Uses Net::SNMP, Tie::IxHash and Time::localtime CPAN modules.

fingers++ for recent post "Cisco SNMP CDP Poll" that inspired me to dig into this.

Critique and suggestions are both welcome and appreciated.
    striving toward Perl Adept
    (it's pronounced "why-bick")

Latest update: 2001-05-20 21:10
Added "Related CPAN modules" to pod.

Cisco SNMP CDP Poll
on May 16, 2001 at 21:45 UTC
by fingers
This started out as a script that gathered CDP info by telnet until I realized I could much less intrusively get the same info from SNMP. Give the script an IP for an argument and it will retrieve some CDP neighbor info from the target and then use that info to acquire the IPs of new targets effectively allowing you to map out all of your cisco gear and how they are connected.

Currently Working On
1. making subs more blackbox-ish
2. more error checking
3. get info such as serial number,
number of ports on device,etc.

EDITED May 16th
Corrected a problem with how the script reacted if it has a neighbor with no ip address. It will now display when it sees a null value for IP.
EDITED May 16th
Cleaned up the code a little bit. Made the get_ip get_name get_port and get_type subs a single sub Get_SNMP_Info
Moved all of the IP conversion code into its own sub Convert_IP
The code should be several steps closer to being strict compliant.
EDITED May 17th
Cleaned things up a lot more. Started using pod, and modified the inline comments to improve readability.
Got rid of get_target sub (it really shouldn't have been a sub at all)
Code now works with strict
(code) Cisco errdisable (no password timeout if Win32)
on May 04, 2001 at 02:36 UTC
by ybiC
Problems with either cable plant or NIC drivers intermittantly cause our ethernet switches at one site to protect themselves by 'error disabling' the port connecting the offending device.   Of course, this causes a particular user to lose network connectivity.   Until we can resolve the root problem, the workaround I've arrived at is to periodically check for errdisabled ports and enable them, after which things work fine until the next hiccup.

This tidbit automates my check for these errdisabled ports.

From a Pelish standpoint, it checks for Win32 and skips password-timeout code plus which doesn't work on that OS.

Debug non-fatal error only seen on Win32:
Argument "" isn't numeric in number gt (>> at line 2569, <STDIN> line 1.

on May 03, 2001 at 22:51 UTC
by idnopheq
ipcalc provides network calcualtions about an IP address.

You can provide the script with mask information in a multitude of ways:


You get the idea ... Enjoy!

p.s. - didn't comment much

UPDATE: Well, don't I feel silly! It has been pointed out that there is already an ipcalc perl script in the world. Was told it's at, but I can't get there now to look at it. I did not mean to step on toes.

(code) Cisco sho ver
on Apr 12, 2001 at 05:49 UTC
by ybiC
Automate collection of Cisco router and LAN switch information for inventory purposes:
    device name, hardware type, IOS/CatOS ver, serial number

From a Perlish standpoint, this has been an excercise in using hashes instead of buckets o' scalar variables or array with obtuse $file[0], and more discriminate use of subroutines so not need passel o' global variables.

2001-04-13 perldoc for details.

Use Net::Snmp sysDescr instead of Net::Telnet::Cisco.
    simplify data structure
    simplify parsing
    simplify program
    improve security

on Apr 04, 2001 at 08:09 UTC
by BlueLines
This is a rewrite of Sys::IP that actually works on unix systems. It has 3 functions:
  • ip() - returns the first non- ip address it can find on the local machine
  • ips() - returns a list of all ips on a local machine.
  • interfaces() - returns a hash of interface/ip address pairs from the local machine
Network Link Status Report Generator
on Mar 27, 2001 at 04:00 UTC
by Big Willy
Generates an HTML report of ping tests for connectivity to the hosts in 'hostfile,' while is formatted as such:


Useful for admins who want to have a cron job intermittently check link status for router-router links, etc. Realize that if you can't ping the host, but can access it by other means this script will not work.
on Mar 13, 2001 at 04:58 UTC
by Falkkin
Net::PingImproved is a modified version of the standard Net::Ping module.

Update: the changes I've made are actually being added to the standard version of Net::Ping, and will probably be incorporated into future versions of Perl. Maintainership of the module may also fall to me. I'll try to post the most recent version of Net::Ping below, for now. :)

Look here for more discussion on why I think this module needs to be altered.

Please look at this module, tear it apart, abuse it, and generally try to find things wrong with it. (And then tell me what you found, or I'll be none better off then when I started ;))

Things I've fixed so far:

  • Got rid of the call to alarm() in ping_tcp(). This call broke any scripts using alarm() (and, by association, sleep(), at least on many machines), and also made the code incompatible with Windows systems. Hence, we now use select() on a non-blocking connect() to implement TCP timeouts.
  • Unfortunately, non-blocking connect() isn't currently supported under Windows either. I fixed this by using system(1, ...) to spawn a new Perl process which attempts to ping the remote host.
  • As an after-effect of changing the method in which ping_tcp() calls connect(), this code now (correctly, in most cases) returns true instead of false if the remote host responded with "Connection refused."

Another thing this module really needs (IMHO) is updated documentation... along with all the code fixes, I'll be working on documentation as well.

on Mar 11, 2001 at 08:26 UTC
by Falkkin
Net::Ping::External is a module that uses your system's default ping command and parses the result. It contains a single public function: ping(). ping() takes in a host and a timeout, and returns true if the system was able to ping the host before the timeout expired, false otherwise.

Look here for more info/discussion on why I am doing this. I need as many monks as possible to test this module, since I will eventually (although not any time soon) be attempting to submit this to CPAN.

- more extensive testing
- support for more esoteric systems

- Fixed support for Win32 systems and generalized the various unix-like pings into one function.
- Added POD, version number, other module-related stuff.

NNTP: Most recent articles in a group
on Mar 08, 2001 at 16:23 UTC
by tomhukins

Prints out the subject and sender of the most recent articles in a newsgroup.

To configure the script's behaviour, set the NUMBER_OF_ARTICLES, GROUP_NAME and SERVER_NAME constants at the top of the script.

I've tried to make this script as resource-friendly as possible for both the client and server. If there's a better way, let me know!

(code)) Cisco Pass Mass - CatOS (deprecated by node 123464)
on Mar 05, 2001 at 09:37 UTC
by ybiC
## deprecated by (code) Poor Man's TACACS - automate CatOS and IOS password resets with Net::Telnet::Cisco and Net::SNMP ##

(code)) Cisco Pass Mass - CatOS (deprecated by node 123464) automates password resets on multiple Cisco CatOS LAN switches.   It's a complete re-write of (code)) Cisco Pass Mass - IOS (deprecated by node 123464), which does the same for Cisco IOS routers and LAN switches.

CatOS switches are a little bit tougher to script, since their password resets are interactive.   Fortunately, I learned of Net::Telnet's waitfor() and getlines() syntax in Network Programming with Perl.   They're pretty straightforward, and Net::Telnet's input_log and dump_log help *a*lot* with debugging.   If you use dump_log, be sure to unlink it when done to avoid leaving your passwords laying around.   Anyway, I suspect this approach is quicker+simpler to code than  

Target switches are either given as command-line arguments, or in a text file - one device name or IP address per line.   Rudimentary sanity checks are done on the input file, but it won't pass -T yet.   It takes a few seconds for each device.   Progress is displayed on-screen and recorded to a logfile.

Comments and critique are both welcome and invited.

Thanks to:
Petruchio for mondo suggestions and help
chromatic for $command =~ $commands[0] suggestion on a different post
ar0n for timeout example at Re: timeout for ?
tilly for tips on functions
strredwolf, jcwren, boo_radley, danger, crazyinsomniac, OeufMayo, azatoth and deprecated for suggestions in CB
Oh yeah, and some guy named vroom.   {grin}

Most recent update: 2001-04-30
hashamafied passel o' scalar vars.
un-subified non-redundant code to reduce number of global vars.
mixed-case subroutine names, w/o ampersan's.
formatted for 75 chars/line (well, mostly)


(code) Cisco Neighbors
on Feb 26, 2001 at 22:51 UTC
by ybiC
Starting with a seed device, discover neighboring Cisco switches/routers.   If run repeatedly, feeding prior output back as input, can generate complete list of Cisco switches/routers in your network.   I use it like that to create input files for (code)) Cisco Pass Mass - IOS (deprecated by node 123464).

Comments and critique are very much welcomed.

Thanks to tilly, fastolfe, japhy, geektron, Petruchio, mkmcconn, boo_radley and chromatic for their suggestions and advice.

LDAP Searcher
on Feb 06, 2001 at 02:58 UTC
by BigJoe
This is a quick LDAP search I did. This gives web users to search our internal "Phone book". I figure when I was trying to throw this together I couldn't find any information on it so here it is for everyone. Thanks to Chromatic for giving me a fix for the Win32 problem with the entry's.
(code)) The Going input/output Rate (deprecated by node 121950)
on Jan 18, 2001 at 00:23 UTC
by ybiC
## deprecated by (code) Net::SNMP, Bandwidth, GnuPlot, PNG, PostScript, Excel ##

Every so often, a sysadmin asks me to check bandwidth utilization by a particular server.   I use tools like CiscoWorks, SNMPc and MRTG for ongoing monitoring, but instead of mucking about with those for one-off checks, I wrote this ditty.

It prompts for switch name/IP, port, number of runs, delay between runs, and (no-echo) passwords, then reports estimated total runtime and output file size, and telnets to the device to collect 5 minute input/output rates.   Output file is csv for easy importing/reporting with Excel or whatever.

In it's present form, commands and parsing are tweaked for Cisco Catalyst 3548 ethernet switch, but should be trivial to add support for other IOS switches (2916, 2924) and routers.   Support for CatOS switches like 6000, 5000, 2948g may take a bit more work.

From a Perlish perspective, it's been an exercise in learning more of for, sleep, if, unless, int, plus subs for readability.   As always, critique and suggestions are more than welcome.

Thanks to: tye and chipmunk for suggestions on how to join output file lines, and to several monks whose names I missed for a flurry o' CB suggestions on integer-checking input.

Update: 2001-04-30
un-subified non-redundant code, for fewer global vars.
hashamafied passel o' scalars.

Out of Band Access Testing
on Feb 27, 2001 at 12:11 UTC
by reyjrar
given an file of "Site name : 9876543210\n"'s it attempts to dial the site and check for success. Success condition is getting to the router/server prompt AFTER successfully completing a login. I noticed some out of band equipment didn't prompt or username/password and figured that was a security risk. use with -v or -l for full effect.
Juniper Router Audit
on Feb 27, 2001 at 12:38 UTC
by cleen
Juniper ( is a provider of high-end routing equipment, even the lower-end juniper equipment (m20) can out-preform cisco's high-end 12k GSR's.

I needed a way to easily audit my juniper configurations on a ever expanding juniper-core based network, thus this was born.

Writing the template configuration file:
Writing the template configuration is a little on the complex side, and it takes a little bit of explaining, so I put the configuration readme at juniper-audit-readme.txt

Overall this code is in beta, and I know there are many things I could do much better, and I intend on doing so, any suggestions and comments would also be great!
IP Accounting parser
on Jan 11, 2001 at 14:49 UTC
by Viking
This parses a log file of ipchains IP accounting data and spits it out as a csv. I use this at work for statistical and billing purposes. It is still a work in progress (but it does work) so I'm interested in any comments. The log file is created from a shell script run from a cron, which you will find at the end of the code.
Thread::Queue for non-threaded apps
on Jan 02, 2001 at 22:06 UTC
by kschwab
I needed functionality somewhat like Thread::Queue for passing data on a queue between a parent and it's forked child. Since non-threaded perl has no Thread::Queue, I used this. It's a bit quick and dirty, but works for me. == Kerry Save money
on Nov 30, 2000 at 09:06 UTC
by mdillon

works like regular whois, but will take a subdomain (or any string used as the domain part of a DNS RR for a subdomain of one of the legacy gTLDs) as input. Requires Net::DNS and Net::ParseWhois.

since Net::ParseWhois only works with the gTLDs COM, ORG, and NET, this code only works with those TLDs as well.

update: now looks up as many domains as are passed on the command line.

for example:

$ ./
Whois Server:

Name: Blockstackers, Inc

        116 E.18th
        Holland, MI 49423

Country: US

Name Servers:
        n/a (n/a)

        Bates, Jeffrey  (JB18794)  hemos@SLASHDOT.ORG
        13268 Riley
        Holland, MI 49424
        Bates, Jeffrey  (JB18794)  hemos@SLASHDOT.ORG
        13268 Riley
        Holland, MI 49424
        Bates, Jeffrey  (JB18794)  hemos@SLASHDOT.ORG
        13268 Riley
        Holland, MI 49424

Record created: n/a
Record updated: n/a
Record expires: n/a
Whois Server:

Name: Maserith Information Systems, LLC
Tag: n/a

        Mikel Smith
        8018 SW Ashford St
        Tigard, OR 97224
        Phone: 503-639-9806

Country: US

Name Servers:
        NS1.DNSWIZ.COM (
        NS3.DNSWIZ.COM (
        NS2.DNSWIZ.COM (
        NS4.DNSWIZ.COM (

        Maserith Information Systesm LLC
        Mikel Smith
        8018 SW Ashford St
        Tigard, OR 97224
        Phone: 503-639-9806
        Maserith Information Systems, LLC
        Mikel Smith
        8018 SW Ashford St
        Tigard, OR 97224
        Phone: 503-639-9806
        Maserith Information Systems, LLC
        Mikel Smith
        8018 SW Ashford St
        Tigard, OR 97224
        Phone: 503-639-9806

Record created: Sun, Jan 28, 1996
Record updated: Wed, Oct 18, 2000
Record expires: Mon, Jan 28, 2002
(code) mind your snmPs & Qs
on Oct 13, 2000 at 10:28 UTC
by ybiC
Query and report on Cisco Catalyst switchport population, plus device location and uptime.   Employs UC-Davis SNMP library and Joe Marzot's CPAN module.

As always, critique and sugestions are welcome and appreciated.

Most recent update: July 11, 2001
- correct calculation error for (live|total) ports.

Thanks to swiftone, geektron, nedv, turnstep, arturo and mdillon for suggestions and improvements.

(code)) Cisco Pass Mass - IOS (deprecated by node 123464)
on Sep 15, 2000 at 16:46 UTC
by ybiC
## deprecated by "(code) Poor Man's TACACS - automate CatOS and IOS password resets with Net::Telnet::Cisco and Net::SNMP" ##

Automate mass config changes (password updates, etc.) for large number of Cisco routers &/or switches.

Comments or critiques are very much welcomed.

Update: Feburary 26, 2001
Rearranged using functions for easier maintenance and greater legibility.
Added function that prompts for devices type (CatOS vs. IOS).

Update: October 27-29, 2000
    Term::Readky for no-echo pw prompts + confirm of new.
    Tie::IxHash for ordered hashes to update passwords.
    Localtime timestamp to $logfile for each device.
    Console preview of target devices list.
    Too many more ToDos.
    Regex's into first tmp loop, to eliminate 2nd $tempfile.
    Console+log prints to subs HEREdocs (improve legibility).

Update: Thanks to ar0n, chromatic, merlyn, Fastolfe, tilly and Joshua Keroes for suggestions and examples that, hopefully, steered me away from Cargo Cult Code and Running With Scissors.   {grin}
on Jun 20, 2000 at 04:04 UTC
by BlueLines
This script should be pretty straightforward. Feed it a network (ip
address/CIDR or ip address/netmask ) and it scans the dns records of said 
network, reporting theresults to STDOUT. Neat. 

Note: This script views the following notations as equivalent:

Rather than reinvent the wheel, I cheated and used Net::Netmask. Eventually
I'll write a sub to handle slash/netmask notation, but until then this program
requires the forementioned module, which is available from cpan.

Here's some example output (and no, none of these machines are publicly
routable, so don't even think about it):

nooky:~$ ./
<----snip----> => => => => => => => => => has no A record => no PTR record

Note that afterglow's A and PTR records matched. Ideally there shouldn't be
anthing in the third column. If there is, then your forward/inverse records
aren't getting along very well.
Push HTTP server
on Jun 11, 2000 at 02:52 UTC
by Corion

This is a non-blocking HTTP-based server for a database which contains temporary highly volatile data. It was written as a proof-of-concept and was designed for stuff like the current status of the dial-up connection or the telephone number of the calling party. It has no access control and no security, but it works with both, specialized clients that keep a connection to the server open and HTTP clients like Internet Explorer. Information can be polled but updated data can also be sent to connected clients. Some documentation is attached as a comment.

(code) MAC n' IP cheese
on Sep 24, 2000 at 07:32 UTC
by ybiC
It's nearly impossible for me to keep server connections labeled correctly at my core switches.   This ditty uses nmap and Net::Ping to build a list of MAC addresses with associated hostnames/IP addresses for live connections on a local subnet/VLAN.   I can then compare it with the switch's CAM table to find what box is connected at which port.

I dabbled with Linux arping utility, but stuck with Net::Ping for one less external dependancy.

Comments or suggestions for improvement are both welcomed and appreciated.

Update 3: 2001-04-30
hashamafied passel o' scalars and minor format cleanup.

Update 2:
cleaned up a few minor Perlish faux pas' and added to-do of using snmpwalk syntax based from riffraff's post in this thread.

thanks to turnstep and to Ovid for feedback, and to ncw for his recent post Numeric list to optimised regexp , which made a no-brainer of regex's to match for nmap input.

on Aug 05, 2000 at 19:08 UTC
by jettero
I saw a nullident.c program at freashmeat. I thought, hmmm, this would be funnier if it was random, and more insulting. They don't need to know who you are anyway.
on Apr 27, 2000 at 18:08 UTC
by ergowolf
This program is GREAT for testing snmp and discovering the community name for the device.
Client for custom file server
on Apr 27, 2000 at 00:02 UTC
by Aighearach
This is the client program for my custom file server, written for inclusion in bots on the Free Internet Chess Server.
Custom file server
on Apr 26, 2000 at 23:57 UTC
by Aighearach
This is a basic file server program. It was written as an example, to be included in a bot on the free internet chess server. Yes, there are modules that make this easy, but the intention was to have a custom, extensible protocol. Currently, it is very basic. In the future, it will be converted to a module, and will be able to identify/convert popular chess notation formats. It has been tested under linux, sunos, and windows. A companion client program will also be provided; check where you found this one.
Log In?

What's my password?
Create A New User
[marto]: cpanmini get you started ?
[marto]: Err minicpan
[atcroft]: floutenvy: I assume you have looked at this already?
[hippo]: marto++
[atcroft]: floutenvy: I assume you have read this already...?
[atcroft]: (Sorry, all, my connection flapped while I was loading the page, causing a resend.)

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-08-17 15:27 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (181 votes). Check out past polls.