Skip to content

jeffWelling/ruby-ifconfig

 
 

Repository files navigation

This is a Ruby wrapper around the ifconfig command.  The goal is to make
getting any information that ifconfig provides easy to access.

It was developed on Linux 2.6 with ifconfig from net-tools 1.60.  It also has
support for SunOS, Darwin and Open, Free, Net, and DragonflyBSD.  These have
not been thoroughly tested.  Non Linux platforms call netstat for interface
packet information

Please send me ifconfig / netstat output for platforms that don't work.

see test/*.rb for usage examples.

Thanks to Peter Johnson for the *BSD examples
Thanks to Jeremy Tregunna for Darwin and DragonflyBSD support

INSTALLATION
------------

Please see the INSTALL file for details of how to install Ruby-Ifconfig

TESTING
-------
> rake
to run all the unit tests.

Prerequisites
------

You must have a working ifconfig binary in your path.
The output format of you particular version of ifconfig must be supported.
Currently this has only been tested with net-tool 1.6 on Linux

Example
------
require 'ifconfig'

cfg = IfconfigWrapper.new.parse        # parses the output of ifconfig

cfg.interfaces           # returns list of interfaces

cfg['eth0'].addresses('inet')   # returns ipv4 address of eth0

cfg.addresses('inet')        # returns list of all ipv4 addresses

cfg['eth0'].status   # returns true if interface is up

cfg.each { block } # run a block on each interface object

LICENCE
-------

This software is offered under the GNU GENERAL PUBLIC LICENSE, a copy of which
is included.

Section 2, paragraph b and section 5 of the GNU General Public License does not apply when the Software (Ruby/Ifconfig) is included in the program Corgi.

--
Daniel Hobe
daniel@nightrunner.com

About

Ruby wrapper around the ifconfig command.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%