Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Python Script for Colorizing Traceroute Output

63 views
Skip to first unread message

Jordan Bylsma

unread,
Nov 17, 2012, 10:04:07 AM11/17/12
to
I'm looking into writing a python script that colorizes particular hops when using traceroute. Anyone run across something like this? I don't think it would be extremely difficult to write but some example code would help.

Basically particular hops in traceroute output would match a table as either a router, firewall or layer 3 switch and be colorized accordingly.

garabik-ne...@kassiopeia.juls.savba.sk

unread,
Nov 17, 2012, 10:18:56 AM11/17/12
to
Jordan Bylsma <jordan....@gmail.com> wrote:
> I'm looking into writing a python script that colorizes particular
> hops when using traceroute. Anyone run across something like this? I
> don't think it would be extremely difficult to write but some example
> code would help.
>

<shameless self-advertising>
Generic Colouriser
http://kassiopeia.juls.savba.sk/~garabik/software/grc.html
</shameless self-advertising>

It includes configuration file for traceroute.

--
-----------------------------------------------------------
| Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ |
| __..--^^^--..__ garabik @ kassiopeia.juls.savba.sk |
-----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!

w...@mac.com

unread,
Nov 17, 2012, 12:06:14 PM11/17/12
to Jordan Bylsma, pytho...@python.org, w...@mac.com
Don't forget that most firewalls don't decrement) the time-to-live number, and unless you REALLY know what to look for, are invisible.

-Bill

On Nov 17, 2012, at 10:04 AM, Jordan Bylsma <jordan....@gmail.com> wrote:

> I'm looking into writing a python script that colorizes particular hops when using traceroute. Anyone run across something like this? I don't think it would be extremely difficult to write but some example code would help.
>
> Basically particular hops in traceroute output would match a table as either a router, firewall or layer 3 switch and be colorized accordingly.
> --
> http://mail.python.org/mailman/listinfo/python-list

w...@mac.com

unread,
Nov 17, 2012, 12:07:27 PM11/17/12
to Jordan Bylsma, pytho...@python.org, w...@mac.com
On Nov 17, 2012, at 10:04 AM, Jordan Bylsma <jordan....@gmail.com> wrote:

> I'm looking into writing a python script that colorizes particular hops when using traceroute. Anyone run across something like this? I don't think it would be extremely difficult to write but some example code would help.
>
> Basically particular hops in traceroute output would match a table as either a router, firewall or layer 3 switch and be colorized accordingly.
> --
> http://mail.python.org/mailman/listinfo/python-list

Roy Smith

unread,
Nov 17, 2012, 1:38:53 PM11/17/12
to
In article <mailman.3774.1353175...@python.org>,
Interesting. If the firewall doesn't decrement TTL (a particular nasty
thing to do, and thus completely expected of a firewall) what REALLY
knowledge would enable you to detect its presence in a traceroute
printout at all?

Chris Angelico

unread,
Nov 17, 2012, 1:45:57 PM11/17/12
to pytho...@python.org
If it's a router, then it definitely should be decrementing TTLs,
though if the firewall is simply a part of another hop, you won't
notice it specifically. What's more common, though, is devices that
decrement TTL and drop packets but don't send back Time Exceeded
messages, giving the classic "* * *" line. I'm not sure if that's what
was being referred to, though. (And they aren't necessarily
firewalls.)

ChrisA

Jordan Bylsma

unread,
Nov 17, 2012, 2:59:17 PM11/17/12
to pytho...@python.org
For this case the firewalls DO respond to TTL(in most cases) and will show in a traceroute. The objective here is to colorize particular devices to easily see what type of devices traffic would traverse across the network. I would be using a database of device hostnames that when they match in traceroute they would be printed a particular color. Something like router=green, layer 3 switch yellow, and firewall red. I'm just looking for a basic script to accomplish this. Nothing too fancy.

Jordan Bylsma

unread,
Nov 17, 2012, 2:59:17 PM11/17/12
to comp.lan...@googlegroups.com, pytho...@python.org

Chris Angelico

unread,
Nov 17, 2012, 5:00:10 PM11/17/12
to pytho...@python.org
On Sun, Nov 18, 2012 at 6:59 AM, Jordan Bylsma <jordan....@gmail.com> wrote:
> For this case the firewalls DO respond to TTL(in most cases) and will show in a traceroute. The objective here is to colorize particular devices to easily see what type of devices traffic would traverse across the network. I would be using a database of device hostnames that when they match in traceroute they would be printed a particular color. Something like router=green, layer 3 switch yellow, and firewall red. I'm just looking for a basic script to accomplish this. Nothing too fancy.

Sounds like the previously-mentioned Generic Colo(u)?ri(s|z)er (and
yes, its README says exactly that) could do that for you. You'd need
to craft a regexp to identify each hostname set, rather than using a
database, but it shouldn't be difficult to write a script to create
grc's config file.

I've never used the program, though, so I have no idea how good it is.
All I've done is download the tar.gz and glance over a few bits (the
licence, mainly - which is mostly-GPL).

By the way, you may wish to consider identifying your devices by IP
address rather than hostname. If your IPs are stable and readable, you
could save yourself the delays of reverse DNS lookups by simply
colorizing the IPs.

ChrisA

Steven D'Aprano

unread,
Nov 17, 2012, 8:18:39 PM11/17/12
to
On Sun, 18 Nov 2012 09:00:10 +1100, Chris Angelico wrote:

[...]
> I've never used the program, though, so I have no idea how good it is.
> All I've done is download the tar.gz and glance over a few bits (the
> licence, mainly - which is mostly-GPL).

"Mostly" GPL? You mean "not GPL".

I really wish people wouldn't invent their own licences. It adds
complexity and confusion to the licencing space. Unless you're a lawyer,
and sometimes even if you are a lawyer, any modification you make to an
established licence could be invalid, or possibly even invalidate the
entire licence.

Licence proliferation hurts us all. Just say No.

http://en.wikipedia.org/wiki/License_proliferation



--
Steven

Chris Angelico

unread,
Nov 17, 2012, 8:27:02 PM11/17/12
to pytho...@python.org
The wording in the file does permit you to use it under the exact
terms of the GPL (though no version is specified). But I agree, we
should stick to a handful of well-known licenses and be done with it.
I like the BSD two-clause, myself, less wordy than the GPL.

ChrisA
0 new messages