<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
  <channel>
    <generator>ManGeek RSS 1.0</generator>
    <title>ManGeek Geekisms</title>
    <link>http://www.mangeek.com/</link>
    <description>Blog of the ManGeek</description>
    <language>en</language>
    <copyright>&copy; 2004-2012 the ManGeek</copyright>
    <pubDate>Mon, 06 Feb 2012 11:19:49 -0600</pubDate>
    <lastBuildDate>Mon, 06 Feb 2012 11:19:49 -0600</lastBuildDate>
    <item>
      <title>Filtering output on linux with color</title>
      <link>http://www.mangeek.com/blogc/59.html</link>
      <guid isPermaLink="true">http://www.mangeek.com/blogc/59.html</guid>
      <category>Computers</category>
      <pubDate>Fri, 03 Jun 2011 18:52:00 -0500</pubDate>
      <description>&lt;p&gt;Last night I found myself desperate to read the output of tail but looking for specific content. (Basically tailing a log file and needing to have the fields pop out at me.) There's no easy colorize command in linux so I did some digging, found something similar and modified it. (This is based on Kenny Moen's &lt;a href="http://www.functor.be/wiki/index.php/Linux_Tail_with_Highlighting"&gt;blog entry&lt;/a&gt; about baretail on unix.)  Anyway, the following perl script will allow any content to be highlighted using a simple regex and a pipe. &lt;br /&gt;&lt;br /&gt;For example, to highlight an entire line wherever named is listed:&lt;br /&gt;tail -f /var/log/messages | colorize --highlight "blue:.*named.*"&lt;br /&gt;&lt;br /&gt;Or to highlight the incoming interface and outgoing interface on a firewall log with red for the inside and green for the outside:&lt;br /&gt;tail -f /var/log/messages | colorize --highlight "red:w+=eth0" --highlight "green:w+=eth1"&lt;/p&gt;&#13;
Enjoy!&lt;br /&gt;&lt;span style="font-family: monospace;"&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;use Getopt::Long qw(:config pass_through);&lt;br /&gt;&lt;br /&gt;my %colors =&lt;br /&gt;(&lt;br /&gt;&nbsp;&nbsp; 'red'&nbsp;&nbsp;&nbsp;&nbsp; =&gt; '41;37;1m',&lt;br /&gt;&nbsp;&nbsp; 'green'&nbsp;&nbsp; =&gt; '42;37;1m',&lt;br /&gt;&nbsp;&nbsp; 'yellow'&nbsp; =&gt; '43;30;1m',&lt;br /&gt;&nbsp;&nbsp; 'blue'&nbsp;&nbsp;&nbsp; =&gt; '44;37;1m',&lt;br /&gt;&nbsp;&nbsp; 'magenta' =&gt; '45;37;1m',&lt;br /&gt;&nbsp;&nbsp; 'cyan'&nbsp;&nbsp;&nbsp; =&gt; '46;30;1m',&lt;br /&gt;&nbsp;&nbsp; 'white'&nbsp;&nbsp; =&gt; '47;30;1m'&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;my @highlights;&lt;br /&gt;GetOptions ("highlight=s" =&gt; \@highlights);&lt;br /&gt;&lt;br /&gt;my $tailargs;&lt;br /&gt;for(my $c = 0; $c &lt; scalar(@ARGV); $c++)&lt;br /&gt;{&lt;br /&gt;&nbsp;&nbsp; $tailargs .= ' ' . $ARGV[$c];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;my $highlightargs;&lt;br /&gt;for(my $c = 0; $c &lt; scalar(@highlights); $c++)&lt;br /&gt;{&lt;br /&gt;&nbsp;&nbsp; my @data&nbsp;&nbsp; = split(/:/, $highlights[$c], 2);&lt;br /&gt;&nbsp;&nbsp; my $color&nbsp; = $colors{$data[0]};&lt;br /&gt;&nbsp;&nbsp; my $search = $data[1];&lt;br /&gt;&lt;br /&gt;&nbsp;&nbsp; $highlightargs .= "s/($search)/\033\[$color\$1\033\[0m/gi; ";&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;while (&lt;&gt;)&lt;br /&gt;{&lt;br /&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eval $highlightargs;&lt;br /&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print $_;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</description>
    </item>
    <item>
      <title>Redundancy with IPtables/netfilter - VRRP</title>
      <link>http://www.mangeek.com/blogc/58.html</link>
      <guid isPermaLink="true">http://www.mangeek.com/blogc/58.html</guid>
      <category>Computers</category>
      <pubDate>Thu, 07 Apr 2011 06:38:00 -0500</pubDate>
      <description>&lt;p&gt;Ever try to setup iptables in a redundant configuration? That's exactly what I recently set out to accomplish and after a few bumps, figured out a nice clean way to accomplish it. Granted, I don't yet have a way to do state failover but for my environment that wasn't a concern. That being said, this was accomplished using iptables and keepalived. I did not use ipvs. I just built two iptables systems and installed keepalived. vrrp is done on the inside interface. Pretty easy other than a few gotchas. Here are some issues I ran into and how I got over them. &lt;/p&gt;&#13;
&lt;ul&gt;&#13;
    &lt;li&gt;&lt;span style="FONT-WEIGHT:bold"&gt;Limited IP addresses on the outside interface&lt;/span&gt;&lt;br /&gt;To get over this issue, I installed both firewalls without an outside IP. I turned all used addresses into virtual interfaces in the config. This way the firewall is not addressable if it's not active. Until it claims an address it stays quiet.&lt;/li&gt;&#13;
    &lt;li&gt;&lt;span style="FONT-WEIGHT:bold"&gt;Keepalived uses gratuitous ARP&lt;/span&gt;&lt;br /&gt;This was unfortunate. I use comcast business for my connection and their router does not support gratuitous ARP. It would keep the old MAC address after a failover. There are ways to get around this using aliased interfaces (look up ip link add link on google) but my way to get around this was much simpler. My firewalls are virtual machines and VMware lets you adjust MAC addresses. Therefore I gave the same MAC address to both machine's external interfaces. To the internet it will look no different than business as usual.&lt;/li&gt;&#13;
    &lt;li&gt;&lt;span style="FONT-WEIGHT:bold"&gt;Routes are not configured on failover&lt;/span&gt;&lt;br /&gt;Because I do not have an IP bound upon failover, the result is that the IP fails over but the routing table is wrong. To get over this I used a notify script as part of the config. You just put a line like line "notify_master /opt/script/masterrouteupdate" in your vrrp_instance configuration directive for the internal interface and in that file, I put:&lt;br /&gt;&lt;em&gt;
