<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>phaq &#187; Networking</title>
	<atom:link href="http://phaq.phunsites.net/category/faq/networking/feed/" rel="self" type="application/rss+xml" />
	<link>http://phaq.phunsites.net</link>
	<description>my daily IT madness</description>
	<lastBuildDate>Mon, 30 Jan 2012 10:07:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Install Icinga with MySQL and IDOUtils on FreeBSD</title>
		<link>http://phaq.phunsites.net/2012/01/28/install-icinga-with-mysql-and-idoutils-on-freebsd/</link>
		<comments>http://phaq.phunsites.net/2012/01/28/install-icinga-with-mysql-and-idoutils-on-freebsd/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 17:24:23 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=920</guid>
		<description><![CDATA[It&#8217;s not hard to install Icinga on FreeBSD, at least if you&#8217;re satisfied with default options. Should you however require Icinga with IDOUtils and MySQL support, then you need to take additional steps. Note: This howto requires a patch to your FreeBSD ports tree. The patch has been submitted to the FreeBSD port maintainers. I [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not hard to install <a href="http://www.icinga.org" target="_blank">Icinga</a> on FreeBSD, at least if you&#8217;re satisfied with default options.<br />
Should you however require Icinga with IDOUtils and MySQL support, then you need to take additional steps.</p>
<p><span id="more-920"></span></p>
<p><b>Note: This howto requires a <a href="http://phaq.phunsites.net/files/2012/01/patch_icinga_1.5.1_idoutils_fbs_port.txt">patch</a> to your FreeBSD ports tree. The patch has been submitted to the FreeBSD port maintainers. I hope that it will eventually end up in the ports tree.</b></p>
<p>My initial readings about this was on the official Icinga docs covering <a href="http://docs.icinga.org/latest/en/quickstart-idoutils-freebsd.html" target="_blank">installing Icinga on FreeBSD with IDOUtils</a>.<br />
However, as it turned out, the docs our a bit outdated, and yet do not reflect a way of doing the install using ports.</p>
<p>So here&#8217;s just a short primer on what I did do install Icinga from ports, imposing as little additional work four you, my fellow reader, as well <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Now let&#8217;s turn to Icinga, which has a port on it&#8217;s own, which you&#8217;ll find it at <strong>/usr/ports/net-mgtm/icinga</strong>. First change to that directory.</p>
<pre>cd /usr/ports/net-mgtm/icinga</pre>
<p>Now download the <a href="http://phaq.phunsites.net/files/2012/01/patch_icinga_1.5.1_idoutils_fbs_port.txt">patch file</a> I made into your ports directory.<br />
The patch will inject a new rc-script for ido2db and enable your port to build IDOutils.</p>
<pre>[root@localhost /usr/ports/net-mgmt/icinga]# fetch http://phaq.phunsites.net/files/2012/01/patch_icinga_1.5.1_idoutils_fbs_port.txt</pre>
<p>Then apply the patch like this:</p>
<pre>[root@localhost /usr/ports/net-mgmt/icinga]# patch -p0 &lt; patch_icinga_1.5.1_idoutils_fbs_port.txt
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- Makefile.org	2012-01-28 16:36:46.000000000 +0000
|+++ Makefile	2012-01-28 17:51:38.000000000 +0000
--------------------------
Patching file Makefile using Plan A...
Hunk #1 succeeded at 27.
Hunk #2 succeeded at 109.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- /dev/null	2012-01-28 18:00:51.000000000 +0000
|+++ files/ido2db.in	2012-01-28 18:00:30.000000000 +0000
--------------------------
(Creating file files/ido2db.in...)
Patching file files/ido2db.in using Plan A...
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- files/pkg-message.in.org	2012-01-28 17:48:37.000000000 +0000
|+++ files/pkg-message.in	2012-01-28 17:49:38.000000000 +0000
--------------------------
Patching file files/pkg-message.in using Plan A...
Hunk #1 succeeded at 4.
done</pre>
<p>Now you&#8217;re ready to configure the port:</p>
<pre>[root@localhost /usr/ports/net-mgmt/icinga]# make config</pre>
<p>Note the now <strong>IDOUtils</strong> option that now has appeared. Check it to enable IDOUtils.</p>
<p><a href="http://phaq.phunsites.net/files/2012/01/idoutils_config_screen.png" rel="lightbox[920]"><img class="aligncenter size-medium wp-image-929" src="http://phaq.phunsites.net/files/2012/01/idoutils_config_screen-300x180.png" alt="" width="300" height="180" /></a></p>
<p>Then compile and install as usual. The port will install also all required dependies, two of them being mysql55-client and libdbi-drivers, both to be found at /usr/ports/databases.</p>
<pre>[root@localhost /usr/ports/net-mgmt/icinga]# make install clean</pre>
<p>Afterwards, you should end up with a few additional files, which would not be installed with the stock FreeBSD port.</p>
<pre>[root@localhost /usr/ports/net-mgmt/icinga]# ls -l /usr/local/bin/ido*
-rwxrwxr--  1 root  wheel  238326 Jan 28 16:53 /usr/local/bin/ido2db
-rwxrwxr--  1 root  wheel   80419 Jan 28 16:53 /usr/local/bin/idomod.o

[root@mgmp-bs01 /usr/ports/net-mgmt/icinga]# ls -l /usr/local/etc/rc.d/ido2db
-r-xr-xr-x  1 root  wheel  738 Jan 28 18:00 /usr/local/etc/rc.d/ido2db</pre>
<p>Now you can enable Icinage and IDO2DB in /etc/rc.conf by adding these lines:</p>
<pre>icinga_enable="YES"
ido2db_enable="YES"</pre>
<p>Of course, you still need to perform the usual Icinga configuration steps, which are not covered in this post.<br />
Please check with the <a href="http://docs.icinga.org/latest/en" target="_blank">official docs</a> for this procedure.</p>
<p>If your configuration is proper, you should notice this in your logs indicating that IDOMOD (IDOUtils) is really working.</p>
<pre>[1327773651] Icinga 1.5.1 starting... (PID=95448)
[1327773651] Local time is Sat Jan 28 18:00:51 UTC 2012
[1327773651] LOG VERSION: 2.0
[1327773651] idomod: IDOMOD 1.5.1 (09-09-2011) Copyright (c) 2005-2008 Ethan Galstad (nagios@nagios.org), Copyright (c) 2009-2011 Icinga Development Team (http://www.icinga.org))
[1327773651] idomod: Successfully connected to data sink.  26 queued items to flush.
[1327773651] idomod: Successfully flushed 26 queued items to data sink.
[1327773651] Event broker module '/usr/local/bin/idomod.o' initialized successfully.
[1327773651] Finished daemonizing... (New PID=95450)</pre>
<p>That&#8217;s it, you conquered the beast!</p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2012/01/28/install-icinga-with-mysql-and-idoutils-on-freebsd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VpnInit AppleScript: Override and Restore Default VPN-Routes on OS X</title>
		<link>http://phaq.phunsites.net/2011/12/29/vpninit-applescript-override-and-restore-default-vpn-routes-on-os-x/</link>
		<comments>http://phaq.phunsites.net/2011/12/29/vpninit-applescript-override-and-restore-default-vpn-routes-on-os-x/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 17:37:04 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=876</guid>
		<description><![CDATA[Years ago I wrote a small script to restore local default route after connecting the RAS VPN on Windows. Now, I made up a similar script to do the same on OS X. The basic idea, now and then, was that I would not want to send all traffic through the VPN. Thus the script [...]]]></description>
			<content:encoded><![CDATA[<p>Years ago I wrote a small script <a href="/2007/06/06/ras_initvbs-override-and-restore-routes-with-windows-ras/">to restore local default route after connecting the RAS VPN on Windows</a>.</p>
<p>Now, I made up a similar script to do the same on OS X.<br />
<span id="more-876"></span><br />
The basic idea, now and then, was that I would not want to send all traffic through the VPN.<br />
Thus the script will assist in restoring your local default route after the VPN connection is established.<br />
Furthermore, it&#8217;ll add some specific routes directed to the VPN.</p>
<p>This way, all your usual traffic (internet, surfing, skype, whatever) is sent through your default gateway, while more specific routes (your business stuff) is sent through the VPN.</p>
<p>Below&#8217;s the code for the initial release. It may lack some details yet, like auto-detecting the tunnel device name, but it does the job already.</p>
<p>Just copy the code into Apple Script Editor and save it to a convenient location. Make sure you save it as &#8220;Application&#8221; and not as &#8220;Script&#8221; (which is the default). You you don&#8217;t, double-clicking the script will open the Script Editor instead of executing the script. Surely, not what you want.</p>
<p>Pay attention to the variables on the top, which need to be edited before you save the Script: _vpn_name, _default_gw, _networks, and _sudo_password (optional).<br />
I hope directions are clear enough from the comments sections.</p>
<pre>
# VpnInit
# ---
# an AppleScript utility to connect your vpn,
# restore local default route and add selected
# routes directed to the VPN only
# thus you'll end up sending only selected
# traffic through the VPN, while the rest
# goes through your local default gateway
# as usual
# ---
# released "as is" under the terms of GPL v2.
# Copyright © 2011 Gianpaolo Del Matto
# 
# r0.1 initial release 2011/12/29
#
# ToDo:
# - hardcoding the "sudo" password is a bad idea, maybe
#	need a better way to get away with it
# - vpn tunnel (utun0) is still hardcoded,
#	should be auto-detected
#

# the name of your vpn connection
#
set _vpn_name to "My VPN"

# your local default gateway
#
set _default_gw to "192.168.1.1"

# your remote networks to pass via VPN, separate multiple with comma
# like so: {"1.2.3.4/30", "5.6.7.8/30"}
#
set _networks to {"192.168.2.1/24"}

# your super-user (root) password
# actually needed to bypass the prompts
# leave empty to get prompted
#
set _sudo_password to ""

# ##################################################################
# DO NOT CHANGE ANYTHING BELOW
# ##################################################################

# kindly borrowed from
# http://www.macosxautomation.com/applescript/uiscripting/index.html
# make sure that support for assistive devices is enabled
#
tell application "System Events"
	if UI elements enabled is false then
		tell application "System Preferences"
			activate
			set current pane to pane id "com.apple.preference.universalaccess"
			display dialog "This script requires access for assistive devices be enabled." &amp; return &amp; return &amp; "To continue, click the OK button and enter an administrative password in the forthcoming security dialog." with icon 1
		end tell
		set UI elements enabled to true
		if UI elements enabled is false then
			display dialog "This script cannot run while access for assistive devices is disabled." &amp; return &amp; "Exiting now." buttons {"OK"} with icon 2
			return "user cancelled"
		end if
	end if
end tell

# now dive into the VPN setup part
#
tell application "System Events"
	set _if_tunnel to "utun0" #	do not change, will be auto-detected, just giving a reasonable default
	tell current location of network preferences
		if exists service _vpn_name then
			# try to connect the VPN service if it's disconnected
			#
			if current configuration of service _vpn_name is not connected then
				connect service _vpn_name
			end if

			# give it some time to settle
			#
			set _retval to false
			repeat until (_retval) is true
				set counter to 0
				repeat while counter is less than 16
					# exit if we get connected
					#
					if current configuration of service _vpn_name is connected then
						set _retval to true
						exit repeat
					end if

					# opt for exit if still not connected after 15 seconds
					#
					if counter is equal to 15 then
						display dialog "VPN '" &amp; _vpn_name &amp; "' is still not connected after 15 seconds. Do you want to keep waiting?" with title "VPN still not connected" buttons {"Yes", "No"}
						if button returned of result is "No" then
							# bail out if user decided not to wait any longer
							#
							set _retval to true
							return
						else
							# otherwise reset the counter so we can trigger again
							#
							set counter to 0
						end if
					end if

					set counter to counter + 1
					delay 1
				end repeat
			end repeat

			# now go to post processing and to the following:
			# - delete default route via vpn
			# - restore original default route
			# - add specific routes to vpn
			#
			if current configuration of service _vpn_name is connected then
				# restore local default route
				#
				do shell script "route delete default" password _sudo_password with administrator privileges
				do shell script "route add default " &amp; _default_gw password _sudo_password with administrator privileges

				# inject custom routes via VPN
				#
				repeat with _network in _networks
					do shell script "route add -interface " &amp; _network &amp; " utun0" password _sudo_password with administrator privileges
				end repeat
			end if
		else
			# bail out if the VPN service does not exist
			#
			display dialog "Given VPN '" &amp; _vpn_name &amp; "' does not exist. Please check the name"
		end if
	end tell
end tell
</pre>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/12/29/vpninit-applescript-override-and-restore-default-vpn-routes-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interface-Statistiken in Cacti für Swisscom CentroGrande erstellen</title>
		<link>http://phaq.phunsites.net/2011/12/13/interface-statistiken-in-cacti-fur-swisscom-centrogrande-erstellen/</link>
		<comments>http://phaq.phunsites.net/2011/12/13/interface-statistiken-in-cacti-fur-swisscom-centrogrande-erstellen/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 22:31:53 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[HowTo's]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=806</guid>
		<description><![CDATA[Als Follow-Up zu meinem letzten Post über den Swisscom CentroGrande Router, widme ich mich nun erneut diesem Gerät. Heute geht es darum, Interface-Statistiken in Cacti zu erzeugen &#8212; und das obwohl der CentroGrande den hierfür nötigen SNMP-Support schmerzlich vermissen lässt. Auch wenn der CentroGrande als Consumer-Gerät positioniert ist, wäre für mich &#8211; und wohl auch [...]]]></description>
			<content:encoded><![CDATA[<p>Als Follow-Up zu meinem letzten Post über den <a href="/2011/12/03/swisscom-centro-grande-aufbohren/">Swisscom CentroGrande</a> Router, widme ich mich nun erneut diesem Gerät. Heute geht es darum, Interface-Statistiken in Cacti zu erzeugen &#8212; und das obwohl der CentroGrande den hierfür nötigen SNMP-Support schmerzlich vermissen lässt.</p>
<p><span id="more-806"></span><br />
Auch wenn der CentroGrande als Consumer-Gerät positioniert ist, wäre für mich &#8211; und wohl auch einige andere &#8211; SNMP das Mittel der Wahl zur Überwachung des Geräts wie auch des Netzwerks.</p>
<p>Wenn man die normalerweise deaktivierte Pirelli Management Console auf dem Router aktiviert, gelangt man zwar an einige offiziel nicht zugängliche Funktionen, SNMP ist da aber definitiv nicht dabei. Zwar kann man über die Pirelli Console die Konfigurationsdatei einsehen &#8211; und findet dort auch Hinweise auf SNMP &#8211; doch selbst wer des SNMP-Feature in der Konfiguration manuell aktiviert, wird nach einem Neustart bitter enttäuscht: Weit und breit kein SNMP aktiv <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>Glücklicherweise kann man aber auch für den CentroGrande Interface-Statistiken erzeugen, auch wenn man dafür gewissermassen mit der Kirche ums Dorf herum gehen muss.</p>
<p>Der Trick liegt im Command Line Interface, welches per Telnet und SSH erreichbar ist. Hier kann mit dem Befehl &#8220;net ifcnt all&#8221; für jede Schnittstelle des Routers eine Statistik ausgegeben werden.<br />
Ersetzt man das Schlüsselwort &#8220;all&#8221; durch die Interface-Bezeichnung, bspw. &#8220;wl0&#8243;, erhält man die jeweiligen Einzelstatistiken.</p>
<p>Im folgenden Beispiel werden die Statistiken zur WAN-Schnittstelle angezeigt:</p>
<p><code><br />
[~] # ssh admin@192.168.100.254<br />
OpenRG> net ifcnt eth5.10<br />
---- Driver statistics: port "LAN Fiber VLAN 10" ----<br />
	Device name: eth5.10 - Type: 48, Ethernet<br />
	Network = WAN<br />
	Port status = Connected<br />
	Counters<br />
	  Rx Packets:        2006090<br />
	  Tx Packets:        2477100<br />
	  Rx Bytes:          835058499<br />
	  Tx Bytes:          2356068887<br />
	  Rx Pkts Errors:    0<br />
	  Tx Pkts Problems:  0<br />
	  Rx Dropped Pkts:   0<br />
	  Tx Dropped Pkts:   0<br />
	  Rx Multicast Pkts: NA<br />
	  Tx Multicast Pkts: NA<br />
	  Rx Broadcast Pkts: NA<br />
	  Tx Broadcast Pkts: NA<br />
	  Collisions:        NA</p>
<p>Returned 0<br />
OpenRG><br />
</code></p>
<p>Wer sich in der Pirelli Console schon umgesehen hat, ist vielleicht angesichts der vielen Schnittstellen etwas überfordert.<br />
Die gute Nachricht: Die meisten davon braucht&#8217;s nur für interne Zwecke und sind für die Überwachung kaum relevant. Daher hier eine Auflistung der notwendigen Schnittstellen und deren Funktion:</p>
<pre>
eth0         Switchport 1
eth1         Switchport 2
eth2         Switchport 3
eth3         Switchport 4
wl0          WLAN Access Point
eth5.10      WAN Schnittstelle (Fiber oder DSL)
</pre>
<p>Damit diese Daten nun für Cacti nutzbar werden, bedarf es eines Hilfsprogramms, welches folgende Schritte durchführt:</p>
<ul>
<li>Login auf den Router</li>
<li>Abrufen der Interface-Ststistiken</li>
<li>Ausgabe der bereinigten Informationen</li>
</ul>
<p>Gerade letzterem kommt eine grosse Bedeutung zu, da die Ausgabe wiederum scriptbasiert verarbeitet werden soll und somit normalisiert werden muss.<br />
Wie dies im Detail aussieht, beschreibt die <a href="http://www.cacti.net/downloads/docs/html/making_scripts_work_with_cacti.html" target="_blank">Cacti-Dokumentation</a>.</p>
<p>Basierend auf einem Beispiel-Script aus dem py-expect Package habe ich eine stark abgewandelte Version erstellt, welche allein dem Auslesen des CentroGrande dient und vollständig parametrisierbar ist.<br />
Damit das Script ausführbar wird, sind zum Beispiel unter Debian die Packages python2.5 und python-pexpect erforderlich.</p>
<p>Das ganze sieht beim Ausführen dann wie folgt aus:</p>
<pre>
[~] # /opt/sbin/cg_ifstats.py -u admin -p password -h 192.168.100.254 -i wl0
RxBytes:4230422745 TxBytes:3249795610
</pre>
<p>Damit steht bereits der erste Baustein bereit. Nun muss Cacti noch entsprechend eingerichtet werden, damit die Script-Ausgabe zur Erstellung von Statistiken verwendet werden.</p>
<p>Anweisungen dazu finden sich ebenfalls in der <a href="http://www.cacti.net/downloads/docs/html/how_to.html" target="_blank">Cacti-Dokumentation</a>.</p>
<p>Die nachfolgenden Schritte verdeutlichen dies anhand einiger Screenshoots.<br />
Man kann &#8211; und darf <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  &#8211; es sich aber auch ein bisschen einfacher machen und einfach das Data Template mit den Abhängigkeiten direkt importieren.<br />
Das Data Template kann zusammen mit dem Python Script <a href='http://phaq.phunsites.net/files/2011/12/cg_ifstats.zip'>hier heruntergeladen</a> werden.</p>
<p>Wer die erforderlichen Schritte selbst durchführen möchte, erstellt zuerst eine sogenannte Date Input Method nach dem gezeigten Vorbild.<br />
Dabei müssen insbesonders die Input wie auch die Output Fields erfasst werden (auf Schreibweise achten).<br />
Die Data Input Method wird unter der Bezeichnung &#8220;CentroGrande &#8211; IFSTATS&#8221; gespeichert.</p>
<p><a href="http://phaq.phunsites.net/files/2011/12/data_input1.png" rel="lightbox[806]"><img src="http://phaq.phunsites.net/files/2011/12/data_input1-300x100.png" alt="" width="300" height="100" class="aligncenter size-medium wp-image-813" /></a></p>
<p>Anschliessend wird ein neues Data Template mit der Bezeichnung &#8220;CentroGrande &#8211; Traffic&#8221; erzeugt.<br />
Unter Data Input Method wird die zuvor erstellte Datenquelle &#8220;CentroGrande &#8211; IFSTATS&#8221; verwendet.</p>
<p><a href="http://phaq.phunsites.net/files/2011/12/data_template1.png" rel="lightbox[806]"><img src="http://phaq.phunsites.net/files/2011/12/data_template1-300x76.png" alt="" width="300" height="76" class="aligncenter size-medium wp-image-814" /></a></p>
<p>Weiterhin benötigt das Data Template die Quelldatensätze, &#8220;traffic_in&#8221; und &#8220;traffic_out&#8221;. Diese werden mit den einzelnen Zählern der Data Input Method &#8220;CentroGrande &#8211; IFSTATS&#8221; verbunden, also &#8220;traffic_in&#8221; mit &#8220;RxBytes&#8221; und &#8220;traffic_out&#8221; mit &#8220;TxBytes&#8221;.<br />
Wichtig ist, dass als &#8220;Data Source Type&#8221; der Typ &#8220;COUNTER&#8221; verwendet wird.</p>
<p><a href="http://phaq.phunsites.net/files/2011/12/data_template2.png" rel="lightbox[806]"><img src="http://phaq.phunsites.net/files/2011/12/data_template2-300x68.png" alt="" width="300" height="68" class="aligncenter size-medium wp-image-815" /></a></p>
<p><a href="http://phaq.phunsites.net/files/2011/12/data_template3.png" rel="lightbox[806]"><img src="http://phaq.phunsites.net/files/2011/12/data_template3-300x68.png" alt="" width="300" height="68" class="aligncenter size-medium wp-image-816" /></a></p>
<p>Unter &#8220;Custom Data&#8221; wird bei allen Feldern die Checkbox &#8220;User Per-Data Source Value&#8221; markiert.<br />
Dies ist erforderlich, damit beim folgenden Erzeugen der Graphen die Werte pro Host und Datenquelle einzeln definiert werden können.</p>
<p><a href="http://phaq.phunsites.net/files/2011/12/data_template4.png" rel="lightbox[806]"><img src="http://phaq.phunsites.net/files/2011/12/data_template4-300x45.png" alt="" width="300" height="45" class="aligncenter size-medium wp-image-817" /></a></p>
<p>Nun fehlt das Graph Template. Hierfür klont man am einfachsten eines der bestehenden Graph Templates, beispielsweise &#8220;Interface &#8211; Traffic (bits/sec, Total Bandwidth)&#8221;.<br />
Das geklonte Graph Template bedarf noch einiger Anpassungen, insbesonders bei den Graph Template Items und Graph Item Inputs.<br />
Als Letztere dienen die bereits zuvor definierten Datenquellen &#8220;traffic_in&#8221; und &#8220;traffic_out&#8221;.</p>
<p><a href="http://phaq.phunsites.net/files/2011/12/graph_template1.png" rel="lightbox[806]"><img src="http://phaq.phunsites.net/files/2011/12/graph_template1-300x100.png" alt="" width="300" height="100" class="aligncenter size-medium wp-image-819" /></a></p>
<p>Die Datenquell muss auch bei den Graph Template Items noch entsprechend zu &#8220;traffic_in&#8221; und &#8220;traffic_out&#8221; angepasst werden. </p>
<p><a href="http://phaq.phunsites.net/files/2011/12/graph_template2.png" rel="lightbox[806]"><img src="http://phaq.phunsites.net/files/2011/12/graph_template2-300x95.png" alt="" width="300" height="95" class="aligncenter size-medium wp-image-820" /></a></p>
<p>Damit wäre soweit alles vorbereit, dass nun ein Host-Objekt für den Centro Grande erfasst werden kann.<br />
Anschliessend werden dem Host-Objekt neue Graphs hinzugefügt.</p>
<p><a href="http://phaq.phunsites.net/files/2011/12/create_graph1.png" rel="lightbox[806]"><img src="http://phaq.phunsites.net/files/2011/12/create_graph1-300x36.png" alt="" width="300" height="36" class="aligncenter size-medium wp-image-811" /></a></p>
<p>Je nach Bedarf werden für einzelne oder alle Schnittstelle (wl0, eth5.10, eth0, usw) die Graphen erzeugt.<br />
Dazu muss man zur besseren Unterscheidung unter Title auch die jeweilige Schnittstellenbezeichnung ergänzt werden.<br />
Ferner sind in den Feldern für Username, Passwort, Hostname und Interface die erforderlichen Daten einzutragen.</p>
<p><a href="http://phaq.phunsites.net/files/2011/12/create_graph2.png" rel="lightbox[806]"><img src="http://phaq.phunsites.net/files/2011/12/create_graph2-300x78.png" alt="" width="300" height="78" class="aligncenter size-medium wp-image-812" /></a></p>
<p><a href="http://phaq.phunsites.net/files/2011/12/graph_list.png" rel="lightbox[806]"><img src="http://phaq.phunsites.net/files/2011/12/graph_list-300x69.png" alt="" width="300" height="69" class="aligncenter size-medium wp-image-818" /></a></p>
<p>Nach Abschluss aller Schritte lassen sich fortan die erzeugten Graphs in Cacti bewundern.</p>
<p><a href="http://phaq.phunsites.net/files/2011/12/graphs.png" rel="lightbox[806]"><img src="http://phaq.phunsites.net/files/2011/12/graphs-300x150.png" alt="" width="300" height="150" class="aligncenter size-medium wp-image-821" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/12/13/interface-statistiken-in-cacti-fur-swisscom-centrogrande-erstellen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Swisscom Centro Grande aufbohren</title>
		<link>http://phaq.phunsites.net/2011/12/03/swisscom-centro-grande-aufbohren/</link>
		<comments>http://phaq.phunsites.net/2011/12/03/swisscom-centro-grande-aufbohren/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 23:51:25 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=799</guid>
		<description><![CDATA[Wer einen Swisscom Centro Grande sein Eigen nennt, mag da vielleicht gelegentlich an die Grenzen stossen, die einem Swisscom hier angedeihen lässt. Angesichts der Komplexität der vielen Funktionen mag es für die breite Masse durchaus Sinn machen, hier den vielfältigen Funktionen, die das von Pirelli Broadband Solutions stammende Gerät eigentlich mitbringt, einen Riegel vorzuschieben &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>Wer einen Swisscom Centro Grande sein Eigen nennt, mag da vielleicht gelegentlich an die Grenzen stossen, die einem Swisscom hier angedeihen lässt.</p>
<p>Angesichts der Komplexität der vielen Funktionen mag es für die breite Masse durchaus Sinn machen, hier den vielfältigen Funktionen, die das von Pirelli Broadband Solutions stammende Gerät eigentlich mitbringt, einen Riegel vorzuschieben &#8211; schliesslich werden dann weniger versierte Anwender auch nicht dazu verleitet, etwas zu verkonfigurieren.<br />
Wer allerdings etwas tiefergehende Konfigurationswünsche hat, wird es zu schätzen wissen, dass man über die Hintertür dennoch an die erweiteren Funktionen des Geräts rankommt.<br />
<span id="more-799"></span><br />
<strong>Ich möchte an dieser Stelle noch darauf hinweisen, dass das nachfolgend beschriebene Vorgehen von Swisscom NICHT unterstützt wird, und dass man bei allfälligen Problemen auf sich alleine gestellt ist. Wer auf dem Centro Grande die versteckten Funktionen freischaltet, tut dies also auf eigene Verantwortung.</p>
<p>Also nochmal zum Mitschreiben: Keine Garantie, kein Support, keine Hilfe (und auch kein Retter) in der Not.</p>
<p>Bitte beachten: Die Anleitung gilt für die Pirelli-Router und nicht für die Motorola-Geräte!<br />
</strong><br />
Darum sollten die an dieser Stelle nur die Hartgesottenen weitermachen, die wissen was sie tun.</p>
<hr size="1">
<p>Wie kommt man nun also an diese &#8220;Magic Features&#8221; ran? Sehr simpel, einfach über die Befehlszeile eine Telnetverbindung auf die IP-Adresse des Centro Grande aufbauen:</p>
<p><code><br />
telnet 192.168.2.1<br />
</code></p>
<p>Ach ja, wer Windows Vista/7 einsetzt, hat standardmässig kein Telnet mehr installiert. Dies kann über die Systemsteuerung nachinstalliert werden. Alternativ kann ich auch <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" target="_blank">PuTTY</a> empfehlen.</p>
<p>Nach erfolgten Login mit dem admin-Konto (das Passwort dazu kann man bei Bedarf im <a href="https://sam.sso.bluewin.ch/my/data/MyData?mode=home&amp;lang=de" target="_blank">Swisscom Kundencenter</a> abfragen), muss man folgenden Befehl eingeben:</p>
<p><code><br />
conf set wbm/admin_wbm a25B06c81<br />
</code></p>
<p>Dies aktiviert die originale Pirelli Management Console, allerdigs erst nach einem Neustart, der mit folgendem Befehl ausgelöst wird:</p>
<p><code><br />
system reboot<br />
</code></p>
<p>Und hier das ganze am Stück:</p>
<pre>
mbp:~ Gianpaolo$ telnet 192.168.2.1
Trying 192.168.2.1...
Connected to 192.168.2.1.
Escape character is '^]'.
Username: admin
Password: ***********
OpenRG&gt; conf set wbm/admin_wbm a25B06c81

Returned 0
OpenRG&gt; system reboot
Connection closed by foreign host.
mbp:~ Gianpaolo$
</pre>
<p>Nach dem Neustart verfügt der Router über zwei Web-Interfaces, einmal das Bekannte von Swisscom unter http://router-ip/ und ein zweites unter http://router-ip/admin.html.</p>
<p>Zugang erhält man mit dem bereits zuvor verwendeten admin-Konto. Gut, es sieht zwar nicht so hübsch aus, wie das Swisscom-eigene GUI, aber dafür kommt man an all die schönen Funktionen ran <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><a href="http://phaq.phunsites.net/files/2011/12/cg_pirelli.png" rel="lightbox[799]"><img src="http://phaq.phunsites.net/files/2011/12/cg_pirelli-300x145.png" alt="" width="300" height="145" class="aligncenter size-medium wp-image-801" /></a></p>
<p>Und was kann das Ding nun so alles?</p>
<p>Neben den USB-Ports, an die man beispielsweise USB-Festplatten oder -Drucker anschliessen kann, sind vor allem die VPN-Funktionen oder der Zugang zum lokalen DNS-Server häufig genutzte Power-Features. Ebenso kommt man an die erweiteren Einstellungen fürs WLAN heran, kann manuelles Routing oder Bridging konfigurieren. Auch lässt sich Remote Management konfigurieren und &#8211; auch bisweilen hilfreich &#8211; die DHCP Lease Time heraufsetzen.<br />
Dazu kommt noch jede Menge weiterer Brimborium, aber das findet ihr am besten selber raus.</p>
<p>Kleiner Tipp am Rande: Von den TR069-Einstellungen unterhalb der Fernverwaltung sollte man tunlichst die Finger lassen &#8211; ebenso wie vom händischen Editieren der Konfigurationsdatei <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
Diese sind für das Remote Management und Upgrade durch Swisscom erforderlich. Im dümmsten aller Fälle könnte eine Fehlkonfiguration dazu führen, dass man kein neues Firmware-Upgrade bekommt, was einen unter Umständen plötzlich Offline und mit abgesägten Hosenbeinen dastehen lässt.</p>
<p>Viel Spass mit dem aufgebohrten Centro Grande <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/12/03/swisscom-centro-grande-aufbohren/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Sleep Timeout on TCL (and Cisco too&#8230;)</title>
		<link>http://phaq.phunsites.net/2011/11/09/sleep-timeout-on-tcl-and-cisco-too/</link>
		<comments>http://phaq.phunsites.net/2011/11/09/sleep-timeout-on-tcl-and-cisco-too/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 23:43:38 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[TCL]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=775</guid>
		<description><![CDATA[Being used to other languages sometime leads to false assumptions, like having the same commands every now and then. While doing some TCL scripting on a Cisco I just had the need for a &#8216;sleep&#8217; command or equivalent. Since no &#8216;sleep&#8217; exists, the &#8216;after&#8217; command will do. Just supply it with the timeout in milliseconds, [...]]]></description>
			<content:encoded><![CDATA[<p>Being used to other languages sometime leads to false assumptions, like having the same commands every now and then.<br />
While doing some TCL scripting on a Cisco I just had the need for a &#8216;sleep&#8217; command or equivalent.</p>
<p>Since no &#8216;sleep&#8217; exists, the &#8216;after&#8217; command will do. Just supply it with the timeout in milliseconds, like this for a 10-second timeout:</p>
<p><code>after 10000</code></p>
<p>Or, with a bit more overhead, but some may think it&#8217;s more readable:</p>
<p><code>after [expr {int(10 * 1000)}]</code></p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/11/09/sleep-timeout-on-tcl-and-cisco-too/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extract and Unify Cisco Device-Types with SNMP and Perl</title>
		<link>http://phaq.phunsites.net/2011/11/02/extract-and-unify-cisco-device-types-with-snmp-and-perl/</link>
		<comments>http://phaq.phunsites.net/2011/11/02/extract-and-unify-cisco-device-types-with-snmp-and-perl/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 16:43:07 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=772</guid>
		<description><![CDATA[Here&#8217;s a short script which I use to extract Cisco device-types from SNMP. Bad enough, most of these devices return their device type ID differently, e.g. sometimes prefixed with an uppercase &#8216;C&#8217;, sometimes without any prefix, then again sometimes we find a suffix. So here&#8217;s a snippet, that makes them look neat, so I can [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a short script which I use to extract Cisco device-types from SNMP.<br />
Bad enough, most of these devices return their device type ID differently, e.g. sometimes prefixed with an uppercase &#8216;C&#8217;, sometimes without any prefix, then again sometimes we find a suffix.</p>
<p>So here&#8217;s a snippet, that makes them look neat, so I can work with simple and unified looking device IDs.<br />
<span id="more-772"></span><br />
Just make sure to fill in your hostnames and the SNMP community.</p>
<pre>
#!/usr/local/bin/perl -w

foreach $_SITE ('hostname1', 'hostname2', 'hostname3', 'hostname4') {

        my $_cpe_snmp_router_type = `/usr/local/bin/snmpget -v2c -c SNMP_COMMUNITY_NAME $_SITE .1.3.6.1.4.1.9.3.6.11.1.3.1`;

        print "debug: $_snmp_router_type \n";

        if ( $_snmp_router_type =~ /.*=\sSTRING:\s\"[cC]?(\d+[a-zA-Z0-9]+?)(?:\s.*)?\"/ ) {
                print "router type: $1 \n";
        } else {
                print "error: failed on extracting device ID!\n";
        }
}
</pre>
<p>And here&#8217;s what we get as output from this script:</p>
<pre>
debug: SNMPv2-SMI::enterprises.9.3.6.11.1.3.1 = STRING: "886"

router type: 886
debug: SNMPv2-SMI::enterprises.9.3.6.11.1.3.1 = STRING: "887VDSL2"

router type: 887VDSL2
debug: SNMPv2-SMI::enterprises.9.3.6.11.1.3.1 = STRING: "c2851 Motherboard with 2GE and integrated VPN"

router type: 2851
debug: SNMPv2-SMI::enterprises.9.3.6.11.1.3.1 = STRING: "C836"

router type: 836
debug: SNMPv2-SMI::enterprises.9.3.6.11.1.3.1 = STRING: "887VDSL2"

router type: 887VDSL2
debug: SNMPv2-SMI::enterprises.9.3.6.11.1.3.1 = STRING: "C836"

router type: 836
debug: SNMPv2-SMI::enterprises.9.3.6.11.1.3.1 = STRING: "877"

router type: 877
debug: SNMPv2-SMI::enterprises.9.3.6.11.1.3.1 = STRING: "871"

router type: 871
debug: SNMPv2-SMI::enterprises.9.3.6.11.1.3.1 = STRING: "1803"

router type: 1803
debug: SNMPv2-SMI::enterprises.9.3.6.11.1.3.1 = STRING: "876"

router type: 876
</pre>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/11/02/extract-and-unify-cisco-device-types-with-snmp-and-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DNS zone split-view configuration with BIND-DLZ</title>
		<link>http://phaq.phunsites.net/2011/11/01/dns-zone-split-view-configuration-with-bind-dlz/</link>
		<comments>http://phaq.phunsites.net/2011/11/01/dns-zone-split-view-configuration-with-bind-dlz/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 23:15:11 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=756</guid>
		<description><![CDATA[Personally I stopped working with pure file-based DNS servers long time ago. Earlier this year I committed an article about BIND-DLZ to german freeX magazine on how to make DNS servers really dynamic. While I&#8217;m not permitted to publish my original article (or parts of it) online, I&#8217;m just following it up in some way, [...]]]></description>
			<content:encoded><![CDATA[<p>Personally I stopped working with pure file-based DNS servers long time ago.<br />
Earlier this year I committed <a href="/2011/03/06/upcoming-article-using-bind-with-dynamic-loadable-zone-dlz-extension/">an article about BIND-DLZ to german freeX magazine</a> on how to make DNS servers really dynamic.<br />
While I&#8217;m not permitted to publish my original article (or parts of it) online, I&#8217;m just following it up in some way, as I have another interesting story to tell.<br />
Today I&#8217;m looing into DNS zone split-view on top of <a href="http://bind-dlz.sourceforge.net/" target="blank">BIND-DLZ</a> &#8212; or in other words: How can my BIND server be authoritative on the public network interface, while be recursive only (thus, ignore any local authoritative zones) on the local network interface?<br />
<span id="more-756"></span><br />
Some may say that this is easy, just run two instances of BIND on the same machine.</p>
<p>Well, yes, but this does apply to each and every situation.<br />
Splitting the authoritative server and the cache has it&#8217;s benefits (and I&#8217;d recommend to do this in most cases), especially when it comes to service availability and &#8211; to some degree &#8211; protection against DDoS. Though it has some drawbacks, amongst them the need for more resources, either in the form of separate boxes, virtual servers or even running the daemon twice on the same box.<br />
In some scenarious, you&#8217;re just bound to the fact, that you&#8217;re limited in resources and simply can&#8217;t run two daemons. Or you need to take extra steps to have your operating system support running two daemons concurrently. Most do not allow that out-of-the-box, so you&#8217;ll find yourself struggling with copying init-scripts and directory structures. This may even break on the next distro upgrade, so maybe it&#8217;s better to not even bother <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </p>
<p>Si, even if it may not be best practice, I want to look into a all-in-one solution for the scenario below:</p>
<p>I have a server, that is connected to the internet on one network interface. The machine acts as authoritative nameserver for a few domains, thus effectively hosting some DNS zones and being the master for them.<br />
As I&#8217;m not too happy with static DNS zone files, I configured the host to serve out it&#8217;s authoritative zone data dynamically through the BIND-DLZ (dynamically loadable zones) extension.<br />
Let&#8217;s call this the &#8216;external&#8217; view, so it&#8217;s actually what we see from the public internet.</p>
<p>Now, the very same server runs some services locally, like an MTA (mail transfer agent) for example.<br />
The DNS server also listens to the loopback interface 127.0.0.1, which was added as first name server in /etc/resolv.conf. Why should we use an external name server if we have one locally already?</p>
<p>Everyone familiar with this kind of topic may notice, that this could actually lead to some issues in a real production environment.<br />
Let&#8217;s asume that a new DNS zone for  &#8216;microsoft.com&#8217; is being added to our authoritative name server.</p>
<p>Since we didn&#8217;t take any special precaution, the following will happen when we send an email message to microsoft.com through our local MTA: First the MTA will look in /etc/resolv.conf for any valid name server. Since we listed 127.0.0.1 as first name server, that&#8217;s the one being queried first.</p>
<p>Remember that we added &#8216;microsoft.com&#8217; as authoritative (primary) zone to our local name server?</p>
<p>Well, for sure, we wouldn&#8217;t want to host &#8216;microsoft.com&#8217; on our own system. That can only be wrong. You may as well substitute any other domain here, which will propably never be hosted with you (yahoo.com, google.com, etc). But as soon as you run some sort of hosting business, you may well end up in situation, that some dumbass will eventually bypass your nice input filters <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>So we end up with our own local name server replying to us with a obviously wrong SOA for the zone &#8216;microsoft.com&#8217;. Even worse, we get wrong MX records as well, so our MTA will deliver the messages to a totally wrong destination. Sure not what we want!</p>
<p>To solve this when running with traditional BIND zone files, you&#8217;d simply extended your named.conf to have multiple views. So you&#8217;d add your authoritative zones to an outside view (requests coming through the public/outside interface), while adding an inside or local view (for requests coming through the local network or loopack interface), where no zones are to be added.</p>
<p>So the question arises if it is possible to incorporate this kind of setup with BIND-DLZ zones setup?</p>
<p>After some testing, the answer to this is clearly yes. Though I must admit I have only tested this with DLZ&#8217;s file-system driver, I think it should actually work with other DLZ drivers as well.</p>
<p>Let&#8217;s look at a very basic named.conf (I omitted most of the options for better readability) with DLZ:</p>
<p><code><br />
options {<br />
	directory	"/etc/namedb/working";<br />
	pid-file	"/var/run/named/pid";<br />
	dump-file	"/var/dump/named_dump.db";<br />
	statistics-file	"/var/stats/named.stats";<br />
	listen-on	{ any; };<br />
};</p>
<p>zone "." { type hint; file "/etc/namedb/named.root"; };</p>
<p>dlz "file system zone" {<br />
	database "filesystem ./dns-root/ .dns .xfr 0 ~";<br />
};<br />
</code></p>
<p>This would just enable a authoritative and recursing name-server, which has it&#8217;s dynamic DLZ zones within the &#8216;dns-root&#8217; directory, but with that exact behaviour as mentioned before.</p>
<p>So, we should now add two views, and external view and a internal view. How do we take them apart? Simple answer: by their source address. Since we run our local cache only through the localhost interface, any request coming from that source should be directed into the internal view.<br />
On the other hand, all requests not coming from the localhost source shall be put into the external view. It may especially important that we then disable recursion on the external view.</p>
<p><code><br />
options {<br />
	directory	"/etc/namedb/working";<br />
	pid-file	"/var/run/named/pid";<br />
	dump-file	"/var/dump/named_dump.db";<br />
	statistics-file	"/var/stats/named.stats";<br />
	listen-on	{ any; };<br />
};</p>
<p>view "external" {<br />
      	match-clients { !127.0.0.1; any; };</p>
<p>      	recursion no;</p>
<p>	zone "." { type hint; file "/etc/namedb/named.root"; };</p>
<p>	dlz "file system zone" {<br />
		database "filesystem ./dns-root/ .dns .xfr 0 ~";<br />
	};<br />
};</p>
<p>view "internal" {<br />
	match-clients { 127.0.0.1; !any; };</p>
<p>	recursion yes;</p>
<p>	zone "." { type hint; file "/etc/namedb/named.root"; };<br />
};<br />
</code></p>
<p>Now let&#8217;s check if this holds true. First I query my authoritative domain &#8216;example.org&#8217; through the hosts public IP on 192.0.2.11</p>
<p><code><br />
$ dig @192.0.2.11 example.org</p>
<p>; &lt;&gt; DiG 9.7.3-P3 &lt;&gt; @192.0.2.11 example.org<br />
; (1 server found)<br />
;; global options: +cmd<br />
;; Got answer:<br />
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 30099<br />
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0<br />
;; WARNING: recursion requested but not available</p>
<p>;; QUESTION SECTION:<br />
;example.org.			IN	A</p>
<p>;; AUTHORITY SECTION:<br />
example.org.		3600	IN	SOA	mynameserver.example.org. hostmaster.example.org. 2004070101 10800 3600 604800 86400<br />
</code></p>
<p>Now I do the same for the domain &#8216;microsoft.com&#8217;:</p>
<p><code><br />
$ dig @192.0.2.1 microsoft.com</p>
<p>; &lt;&gt; DiG 9.7.3-P3 &lt;&gt; @192.0.2.1 microsoft.com<br />
; (1 server found)<br />
;; global options: +cmd<br />
;; Got answer:<br />
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: REFUSED, id: 15463<br />
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0<br />
;; WARNING: recursion requested but not available</p>
<p>;; QUESTION SECTION:<br />
;microsoft.com.			IN	A<br />
</code></p>
<p>As expected I get no reply (actually it&#8217;s refused, since recursion is turned off).</p>
<p>Now I query again for example.org, but this time not on the external but on the loopback interface.</p>
<p><code><br />
$ dig @localhost example.org</p>
<p>; &lt;&gt; DiG 9.6.-ESV-R3 &lt;&gt; @localhost example.org<br />
; (2 servers found)<br />
;; global options: +cmd<br />
;; Got answer:<br />
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 49769<br />
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3</p>
<p>;; QUESTION SECTION:<br />
;example.org.			IN	A</p>
<p>;; ANSWER SECTION:<br />
example.org.		172800	IN	A	192.0.43.10</p>
<p>;; AUTHORITY SECTION:<br />
example.org.		172800	IN	NS	b.iana-servers.net.<br />
example.org.		172800	IN	NS	a.iana-servers.net.</p>
<p>;; ADDITIONAL SECTION:<br />
a.iana-servers.net.	1800	IN	A	199.43.132.53<br />
a.iana-servers.net.	1800	IN	AAAA	2001:500:8c::53<br />
b.iana-servers.net.	1800	IN	A	199.43.133.53<br />
</code></p>
<p>Here I get the reply through dns recursion. Thus indeed my local zone for &#8216;example.org&#8217; is completely ignored, despite we run the authoritative zone from the same instance.</p>
<p>So to summarize: Even when running my authoritative zones off BIND-DLZ, adding views to BIND can still divide one single BIND instance into authoritative and recursing-only instance without interfering with local services, even if a domain is erronously added the the authoritative view.</p>
<p>As a plus, I tested if it&#8217;s possible to run different BIND-DLZ namespaces for external and internal views. The good news: This also works fine. The config, in the example of the DLZ file system driver, may look like this:</p>
<p><code><br />
options {<br />
	directory	"/etc/namedb/working";<br />
	pid-file	"/var/run/named/pid";<br />
	dump-file	"/var/dump/named_dump.db";<br />
	statistics-file	"/var/stats/named.stats";<br />
	listen-on	{ any; };<br />
};</p>
<p>view "external" {<br />
      	match-clients { !127.0.0.1; any; };</p>
<p>      	recursion no;</p>
<p>	zone "." { type hint; file "/etc/namedb/named.root"; };</p>
<p>	dlz "file system zone" {<br />
		database "filesystem ./dns-root-ext/ .dns .xfr 0 ~";<br />
	};<br />
};</p>
<p>view "internal" {<br />
	match-clients { 127.0.0.1; !any; };</p>
<p>	recursion yes;</p>
<p>	zone "." { type hint; file "/etc/namedb/named.root"; };</p>
<p>	dlz "file system zone" {<br />
		database "filesystem ./dns-root-int/ .dns .xfr 0 ~";<br />
	};<br />
};<br />
</code></p>
<p>In this example, I just added two separate DNS root directories, each of which can hold different authoritative zone data. Thus you can really take full adtvange of the BIND split views by having the very same domains an external and an internal set of records, each separate of the other.</p>
<p>Quiet cool, isn&#8217;t it? <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/11/01/dns-zone-split-view-configuration-with-bind-dlz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RegExp Filter: Extract complete interface blocks without &#8216;shutdown&#8217; statement</title>
		<link>http://phaq.phunsites.net/2011/07/14/regexp-filter-extract-complete-interface-blocks-without-shutdown-statement/</link>
		<comments>http://phaq.phunsites.net/2011/07/14/regexp-filter-extract-complete-interface-blocks-without-shutdown-statement/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 13:13:11 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RegExp]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=685</guid>
		<description><![CDATA[A project I&#8217;m currently working on involges much Regurlar Expressions trickery to parse values from Cisco&#8217;s running configuration. Here&#8217;s how to extract a complete interface block not in &#8216;shutdown&#8217; state. Imagine a Cisco configuration block like this: ! interface BRI0 no ip address encapsulation hdlc shutdown ! And here the same again without the &#8216;stutdown&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>A project I&#8217;m currently working on involges much Regurlar Expressions trickery to parse values from Cisco&#8217;s running configuration.<br />
Here&#8217;s how to extract a complete interface block not in &#8216;shutdown&#8217; state.<br />
<span id="more-685"></span><br />
Imagine a Cisco configuration block like this:</p>
<p><code><br />
!<br />
interface BRI0<br />
 no ip address<br />
 encapsulation hdlc<br />
 shutdown<br />
!<br />
</code></p>
<p>And here the same again without the &#8216;stutdown&#8217; statement:</p>
<p><code><br />
!<br />
interface BRI0<br />
 no ip address<br />
 encapsulation hdlc<br />
!<br />
</code></p>
<p>Thinking about a case where you want to extract just these blocks from multiple config files, but only if they don&#8217;t contain the &#8216;shutdown&#8217; statement. The solution to this with Regular Expressions is called negative look-ahead, so to speak &#8220;match something not followed by something else&#8221;.</p>
<p>The trick is to make anchored matches within the context we&#8217;re searching.<br />
Looking at the block, we get multiple anchors:</p>
<ul>
<li>&#8216;interface&#8217; following by the interface name and line feed/carriage return as our beginning marker</li>
<li>a line starting with an exclamation mark marking the end of the block</li>
<li>any number of lines in between starting with at least 1 whitespace character</li>
</ul>
<p>So an extended expression, which would match just this criteria looks like this:</p>
<pre>/^interface .*[\r\n]+(?:^\s.*[\r\n])+(?:^![\r\n]+)+/m</pre>
<p>This would match any interface configuration block.<br />
Now if we want only the interface in &#8216;no shutdown&#8217; state, we add a negative look-ahead which can be spoken of as this:</p>
<ul>
<li>any number of lines in between starting with at least 1 whitespace character NOT followed by the word &#8216;shutdown&#8217;</li>
</ul>
<p>Thus, our expression now looks like this:</p>
<pre>/^interface .*[\r\n]+(?:^\s(?!shutdown).*[\r\n])+(?:^![\r\n]+)+/m</pre>
<p>This will return just the matches for interfaces in &#8216;no shutdown&#8217; state.</p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/07/14/regexp-filter-extract-complete-interface-blocks-without-shutdown-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Serve files quickly using built-in python Web-Server in OS X</title>
		<link>http://phaq.phunsites.net/2011/07/13/serve-files-quickly-using-built-in-python-web-server-in-os-x/</link>
		<comments>http://phaq.phunsites.net/2011/07/13/serve-files-quickly-using-built-in-python-web-server-in-os-x/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 18:31:46 +0000</pubDate>
		<dc:creator>gdelmatto</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=673</guid>
		<description><![CDATA[Mac OS X (since 10.5) sports a python environment in it&#8217;s default install, which includes a very simple HTTP server. This may come in handy if you want to serve some files quickly over HTTP, without the need to fireup the full-blown Apache available through &#8216;Web Sharing Service&#8217;. Don&#8217;t believe me? Read on to see [...]]]></description>
			<content:encoded><![CDATA[<p>Mac OS X (since 10.5) sports a python environment in it&#8217;s default install, which includes a very simple HTTP server.<br />
This may come in handy if you want to serve some files quickly over HTTP, without the need to fireup the full-blown Apache available through &#8216;Web Sharing Service&#8217;.<br />
Don&#8217;t believe me? Read on to see how you&#8217;ll be up in running in just a few seconds.<br />
<span id="more-673"></span><br />
To launch the simple HTTP server, start a Terminal first, then change to the directory containing the files you want to serve, e.g. your Downloads folder:</p>
<p><code><br />
$ cd ~/Downloads<br />
</code></p>
<p>Now fire up the web server like this:</p>
<p><code><br />
$ python -m SimpleHTTPServer<br />
Serving HTTP on 0.0.0.0 port 8000 ...<br />
</code></p>
<p>This will bind to port 8000 by default. To use another port, just give the TCP port as an additional argument on the command line:</p>
<p><code><br />
$ python -m SimpleHTTPServer 8100<br />
Serving HTTP on 0.0.0.0 port 8100 ...<br />
</code></p>
<p>To access the server, open the link as http://Your-Macs-IP-Address:8000 (or http://Your-Macs-IP-Address:8100 for the second example).<br />
This will provide you with a simple file list to browse and access your files.</p>
<p>You won&#8217;t be able to bind to the HTTP default port 80 with regurlar user accounts however. This will only yield a &#8220;socket: [Errno 13] permission denied&#8221; error message.</p>
<p>To bind to port 80, you need to run the command through &#8216;sudo&#8217; like this:</p>
<p><code><br />
$ sudo python -m SimpleHTTPServer 80<br />
Password:<br />
Serving HTTP on 0.0.0.0 port 80 ...<br />
</code></p>
<p>The server will stay in foreground of the Terminal and keep running until you hit CTRL-C.</p>
<p>If you want to know why I needed this, then read on my efforts on <a href="/2011/07/13/tricking-squeezebox-server-into-downloading-firmware-files-from-local-server/">upgrading Squeezebox Radio firmare</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/07/13/serve-files-quickly-using-built-in-python-web-server-in-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable LCD backlight permanently on QNAP TS-459 II</title>
		<link>http://phaq.phunsites.net/2011/07/06/enable-lcd-backlight-permanently-on-qnap-ts-459-ii/</link>
		<comments>http://phaq.phunsites.net/2011/07/06/enable-lcd-backlight-permanently-on-qnap-ts-459-ii/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 23:14:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Operating Systems]]></category>

		<guid isPermaLink="false">http://phaq.phunsites.net/?p=663</guid>
		<description><![CDATA[So you got one of these QNAP TS-459 II NAS boxes and want the fancy LCD being permantly backlit? Here&#8217;s how to do it&#8230; I recommend to have the Optware (IPKG) package from the QPKG repository installed. While not strictly required, it will provide an framework to keep our changes persistent after reboots. Installing QPKG [...]]]></description>
			<content:encoded><![CDATA[<p>So you got one of these QNAP TS-459 II NAS boxes and want the fancy LCD being permantly backlit?<br />
Here&#8217;s how to do it&#8230;<br />
<span id="more-663"></span><br />
I recommend to have the <a href="http://www.qnap.com/de/QPKG_detail.asp?qp_id=116" target="_blank">Optware (IPKG)</a> package from the QPKG repository installed. While not strictly required, it will provide an framework to keep our changes persistent after reboots.</p>
<p>Installing QPKG packages is made easy, just download the QPKG to your computer and install them from the QNAP admin panel.<br />
You&#8217;ll find <a href="http://www.qnap.com/de/QPKG.asp" target="_blank">further readings</a> on this topic on the QNAP homepage.</p>
<p>If you have just a brand new setup of Optware, you must enable it to run startup scripts automatically as pointed out in QNAP Wiki in section <a href="http://wiki.qnap.com/wiki/Install_Optware_IPKG#Running_.2Fopt.2Fetc.2Finit.d.2F.2A_on_startup" target="_blank">Running /opt/etc/init.d/* on startup</a>.</p>
<p>If have you have already some services installed through Optware, like cron or snmpd, then the next step is not required.<br />
Otherwise, you may need to create a few directories and set proper permissions, as these may not yet exist.</p>
<pre>
mkdir -p /opt/sbin /opt/etc/init.d
chown admin:administrators /opt/sbin /opt/etc/init.d
chmod 755 /opt/sbin /opt/etc/init.d
</pre>
<p>So, after you successfully installed Optware (IPKG), let&#8217;s move on with our backlight stuff.<br />
Save the code below to a new file at /opt/sbin/lcd_backlight.</p>
<pre>
#!/bin/sh
#
# lcd_backlight - tries to keep front lcd lit at all times <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />
#
while [ : ]; do
	# redirect lcd_tool output to nirvana
	# occasionally there'll be a 'cannot control LCD' message
	# but well, actually, who cares? <img src='http://phaq.phunsites.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />
	/sbin/lcd_tool -o &gt; /dev/null 2&gt;&amp;1
	/bin/sleep 5
done
</pre>
<p>Don&#8217;t forget to make the new script executable:</p>
<p><code><br />
# chmod 755 /opt/sbin/lcd_backlight<br />
</code></p>
<p>Now, you can always login through SSH and run /opt/sbin/lcd_backlight to have LCD backlight permanently turned on.</p>
<p>Maybe you want this to start automatically every time you reboot the box?<br />
Add another script at /opt/etc/init.d/S99lcd-backlight with this contents:</p>
<pre>
#!/bin/sh

RETVAL=0
QPKG_NAME="LCD_Backlight"
QPKG_DIR=

_exit()
{
    echo -e "Error: $*"
    echo
    exit 1
}

case "$1" in
  start)
	echo "Enabling permanent LCD backlight ..."
	/opt/sbin/lcd_backlight &amp;
	RETVAL=$?
	;;
  stop)
	echo "Disabling permanent LCD backlight ... "
	/bin/ps aux|/bin/grep lcd_backlight|/bin/grep -v grep|/bin/grep -v stop|/bin/awk '{ print $1 }'|/usr/bin/xargs kill -9
	RETVAL=$?

	/bin/sleep 3
	;;
  restart)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
esac

exit $RETVAL
</pre>
<p>Make this executable as well:</p>
<p><code><br />
chmod 755 /opt/etc/init.d/S99lcd-backlight<br />
</code></p>
<p>This hack will permanently enable the LCD backlight. Even that the output is suppressed, it shall be noted that the &#8216;lcd_tool&#8217; binary spills a &#8216;Cannot control LCD&#8217; message every now and then. This seems to mean no harm. However, enabling the LCD backlight permanently is probably neither intended nor supported by the vendor. You do this at your own risk.</p>
]]></content:encoded>
			<wfw:commentRss>http://phaq.phunsites.net/2011/07/06/enable-lcd-backlight-permanently-on-qnap-ts-459-ii/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

