<?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>AR-IX.net Blog</title>
	<atom:link href="http://blog.ar-ix.net/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.ar-ix.net</link>
	<description>Technobabble and other talk</description>
	<lastBuildDate>Tue, 20 Sep 2011 12:04:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>VMware vSphere and your firewall</title>
		<link>http://blog.ar-ix.net/archives/89</link>
		<comments>http://blog.ar-ix.net/archives/89#comments</comments>
		<pubDate>Thu, 14 Jul 2011 12:35:22 +0000</pubDate>
		<dc:creator>Lammert Hellinga</dc:creator>
				<category><![CDATA[Virtualisation]]></category>

		<guid isPermaLink="false">http://blog.ar-ix.net/?p=89</guid>
		<description><![CDATA[As some of you may know, I&#8217;ve started working for my new employer last month. I&#8217;m now busy with my so called Masterclass and for that I&#8217;m attending a lot of courses. A couple of weeks ago I attended a &#8230; <a href="http://blog.ar-ix.net/archives/89">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As some of you may know, I&#8217;ve started working for my new employer last month.</p>
<p>I&#8217;m now busy with my so called Masterclass and for that I&#8217;m attending a lot of courses. A couple of weeks ago I attended a five-day VMware vSphere course and in a while I will take an exam and try to get my VCP4 certification.</p>
<p>At home I&#8217;ve created a labsetup so I can fiddle around with ESXi, vCenter server, etc. without breaking any setups. Today I was trying to get a connection to my vCenter server from work but that involves opening a couple of ports in your firewall or, in my case, tunneling a few towards my home. At first it was unclear to me which ports should and shouldn&#8217;t be opened. I found this <a href="http://www.virtualinsanity.com/index.php/2009/09/22/update-connections-and-ports-in-esx-and-esxi/" target="_blank">page </a>which provides this <a href="http://www.virtualinsanity.com/wp-content/uploads/connections-ports-esx-v3.pdf" target="_blank">pdf</a>. This is a great diagram mentioning all ports for all connections typically used in your vSphere environment.</p>
<p>I found this to be very usefull and therefore like to share it with you as well.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ar-ix.net/archives/89/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSONBOT plugin</title>
		<link>http://blog.ar-ix.net/archives/78</link>
		<comments>http://blog.ar-ix.net/archives/78#comments</comments>
		<pubDate>Mon, 16 May 2011 14:28:42 +0000</pubDate>
		<dc:creator>Lammert Hellinga</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Systems Administration]]></category>

		<guid isPermaLink="false">http://blog.ar-ix.net/?p=78</guid>
		<description><![CDATA[Afternoon y&#8217;all! Last weekend I decided to give observium a try. Observium is a network monitoring system and fully snmp-based. There are also alternatives like Zabbix and/or Nagios but Observium differs that it&#8217;s very very easy to set-up. I&#8217;ve spent &#8230; <a href="http://blog.ar-ix.net/archives/78">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Afternoon y&#8217;all!</p>
<p>Last weekend I decided to give <a title="observium" href="http://www.observium.org" target="_blank">observium</a> a try. Observium is a network monitoring system and fully snmp-based. There are also alternatives like Zabbix and/or Nagios but Observium differs that it&#8217;s very very easy to set-up.</p>
<p>I&#8217;ve spent like half-an hour installing observium on a clean debian server and after those 30 minutes it was already graphing 3 devices in my network. I&#8217;ve spent a couple of hours after that toying around, discovering what&#8217;s possible and what not.</p>
<p>Something observium does is when it discovers a problem, for example a device that got disconnected, it sends an e-mail to the snmp-syscontact (or if overridden another email address).</p>
<p>I usually also have an irc window open when I&#8217;m sitting behind my computer like many of you I suppose. And I almost immediately had the wish that the irc-bot (<a title="jsonbot" href="http://jsonbot.org/" target="_blank">jsonbot</a>) that I have running would be connected somehow to observium and inform me of those messages. A couple of friends also use observium (one of them has been pushing me around a lot when o when I would start using observium <img src='http://blog.ar-ix.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ) and they also liked the idea.<br />
<span id="more-78"></span></p>
<p>So today I got up around 8:30 in the morning brewed a fresh pot of coffee and opened my editor. Now some hours and I don&#8217;t know how many cups of coffee later I&#8217;d like to present to you my observium-jsonbot-plugin!</p>
<p>What it does is check an imap e-mail box for new messages and inform you about it. The features it provides are:</p>
<ul>
<li>Present a list of unread e-mails</li>
<li>Display the contents of a given message</li>
<li>Automatically check for new messages (by default every 60 secs. when enabled)</li>
</ul>
<p>Here&#8217;s how it works! First of all you need to configure your bot with the options for the observium imapbox. The following options can be set:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">imap-host (default: mail.example.com)<br />
imap-username (default: observ@example.com)<br />
imap-password (default: password)<br />
imap-folder (default: INBOX)<br />
imap-ssl (default: True)<br />
imap-interval (default: 60)<br />
watcher-enabled (default: False)</div></div>
<p>These options can be set using:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">!observium-cfg<br />
<br />
#Example<br />
!observium-cfg imap-host mail.yourdomain.com<br />
<br />
# Don't forget to save and reload when you're done using:<br />
!observium-cfgsave<br />
#and<br />
!reload observium</div></div>
<p>When you&#8217;ve configured the plugin these are the commands available to you:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># retrieve all unread message-subjects from the configured imap-folder<br />
!observ<br />
<br />
#example output:<br />
[#3] Device Up: host.yourdomain.tld<br />
[#2] Device Down: host.yourdomain.tld<br />
<br />
# retrieve the contents of a specific message<br />
!observ-msg 3<br />
<br />
#example output:<br />
[Subject]: Device Up: host.yourdomain.tld<br />
[Message]: Device up: host.yourdomain.tld at 16-05-2011 10:45:56<br />
<br />
# if you've enabled the watcher in the config you can enable it for the current channel using:<br />
!observ-watch-enable<br />
<br />
#or disable it using:<br />
!observ-watch-disable<br />
<br />
#or list the channels for which it has been enabled:<br />
!observ-watch-list</div></div>
<p>If you&#8217;ve enabled the watcher for a certain channel the bot will check the mailbox every 60 seconds (unless you&#8217;ve changed the interval) and if new messages have been found it will post a list of subjects in the channel.</p>
<p>Of course you&#8217;ve been waiting for the downloadlink: well here it is: <a title="Download" href="http://blog.ar-ix.net/downloads/code/python/jsbplugs/observium.py" target="_blank">Download</a></p>
<p>You should put this file in &lt;yourbotdirectory&gt;/jsb/plugs/socket/<br />
Then restart your bot and enable the plugin using:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">!plug-enable observium</div></div>
<p>I hope you have fun with it and if you&#8217;ve got any comments and/or find bugs, please let me know <img src='http://blog.ar-ix.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Kind regards,</p>
<p>Lammert</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ar-ix.net/archives/78/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Site-2-Site VPN using IPSec</title>
		<link>http://blog.ar-ix.net/archives/29</link>
		<comments>http://blog.ar-ix.net/archives/29#comments</comments>
		<pubDate>Thu, 05 May 2011 20:45:56 +0000</pubDate>
		<dc:creator>Lammert Hellinga</dc:creator>
				<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://blog.ar-ix.net/?p=29</guid>
		<description><![CDATA[This is the first out of a series of 3 posts I&#8217;m about to make. These posts will cover setting up an Site-2-Site IPSec VPN tunnel, GRE tunneling and iBGP. This post will cover setting up an Site-2-Site IPSec VPN &#8230; <a href="http://blog.ar-ix.net/archives/29">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is the first out of a series of 3 posts I&#8217;m about to make. These posts will cover setting up an Site-2-Site IPSec VPN tunnel, GRE tunneling and iBGP. This post will cover setting up an Site-2-Site IPSec VPN tunnel between a Cisco 2600 Series router and a Debian box running ipsec-tools and racoon.</p>
<p>As I&#8217;ve mentioned before I&#8217;ve wanted to create a VPN setup between my home and my VPS&#8217;es. Not because it&#8217;s necessary but just because it&#8217;s possible and I learn something from it.</p>
<p>A couple of weeks ago I finally started this project, reading documentation and try to get it working. I started off creating a suitable test-setup here at my house. I booted one of my Cisco 2651XM&#8217;s with a IOS 12.4 image and gave it a clean configuration. 1 ethernet port connected to my home-network so I had a way in and the other connected to a dedicated server which I provided with a fresh Debian install just for this exercise.</p>
<p>With this test-setup I had clean configs, no software or other things that might interrupt this exercise and if I somehow created a big mess it wouldn&#8217;t interfere with my production setup.</p>
<p>So with all things ready it&#8217;s time to start configuring everything. Before I start pasting and explaining my configs let me remind you of one thing. Everything i did is a way of doing it. It&#8217;s not the right way, it&#8217;s not the wrong way, it&#8217;s just the way I did it and there are numerous other ways of accomplishing the same result.<br />
<span id="more-29"></span></p>
<p>There are a couple of ways setting up an IPSec tunnel. You can use pre-shared-keys or PSK in short. Or you can use certificates. I used pre-shared-keys so I won&#8217;t go into using certificates as I&#8217;m sure there are plenty of websites covering that subject.</p>
<p>The other thing that&#8217;s useful to know, which is also a great help when you&#8217;re debugging IPSec, is that when setting up a IPSec tunnel it performs several steps creating the tunnel. Before your tunnel is up and running it performs a couple of checks and negotiations and when both sides agree your tunnel will come up. These steps for creating the tunnel are IKE phase 1 and IKE phase 2. IKE is short for Internet Key Exchange.</p>
<p>During phase 1 it will compare the policies on both sides checking if they agree on encryption, hash-algorithm, etc. and it will check if the PSK matches on both sides. If both sides have identical policies and PSK&#8217;s then they will proceed into the next step, IKE phase 2. If for some reason things don&#8217;t match up on both ends it will end in phase 1 and you&#8217;re probably need to debug to see what&#8217;s going wrong.</p>
<p>Next up is IKE phase 2. When phase 1 is successfully completed, phase 2 is started. Phase 2 negotiates the IPSec security associations and generates the required key material for IPSec. You can specify one or more transform-sets but they have to match on both sides for IPSec to work. If phase 2 is also completed without errors your tunnel will be operational and you can securely transfer data from and to both hosts in this setup.</p>
<p>Next I will show the necessary configuration for the cisco router as well as the configuration for the linux machine. I will try to explain these configurations as much as possible so you can understand which part is for which IKE phase and why it&#8217;s necessary.</p>
<h2>The Cisco Side</h2>
<p>I&#8217;ll start off with the Configuration for the cisco router, I assume you know how to configure a cisco router yourself because I will not be including those parts of the configuration. Only the necessary parts are shown.<br />
Also i&#8217;ve used 3DES encryption for the sake of example, 3DES is not the most secure encryption around, you should use SHA256 of SHA512 instead:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">crypto isakmp policy 1<br />
&nbsp; encr 3des<br />
&nbsp; authentication pre-share<br />
&nbsp; group 2<br />
&nbsp; lifetime 3600<br />
crypto isakmp key YOURKEY address 10.20.30.42 no-xauth<br />
!<br />
!<br />
crypto ipsec transform-set hostb-transform esp-3des esp-sha-hmac<br />
&nbsp; mode transport<br />
!<br />
crypto map hostb-cryptomap 1 ipsec-isakmp<br />
&nbsp; set peer 10.20.30.42<br />
&nbsp; set transform-set hostb-transform<br />
&nbsp; set pfs group2<br />
&nbsp; match address hostb-list<br />
!<br />
interface FastEthernet0/1<br />
&nbsp; ip address 10.20.30.40 255.255.255.0<br />
&nbsp; duplex auto<br />
&nbsp; speed auto<br />
&nbsp; crypto map hostb-cryptomap<br />
!<br />
ip access-list extended hostb-list<br />
&nbsp; permit ip host 10.20.30.40 host 10.20.30.42<br />
!</div></td></tr></tbody></table></div>
<p>I&#8217;ll walk through this configuration step by step explaining every part.</p>
<p>First up is our isakmp policy which you&#8217;ll find on lines 1 through 5. These lines specify your policy used in the IKE phase 1 part which I&#8217;ve mentioned above. Since it&#8217;s logical to assume you might want to create more IPSec tunnels than just 1 you can create more policies than 1. Because not all remote ends might use the same policy. I&#8217;ve created this isakmp policy with priority 1 which is the highest priority. The bigger the number, the lower the priority.</p>
<p>Within this policy we specify a couple of things. First of all on line 2 we say we want to use 3des encryption in our communications with the remote host. On line 3 we specify we want to authenticate using a pre-shared-key. On line 4 we say we want to use diffie-hellman group 2 which is a way of exchanging the PSK securely over an insecure medium and group 2 says it will be using 1024-bit encryption. On line 5 we specify a lifetime of 1 hour.</p>
<p>Line 6 specifies the pre-shared-key for the specified remote host in this case 10.20.30.42 be sure to replace YOURKEY with your own and more secure pre-shared-key. A way of generating a secure key is executing the following command on a *nix machine which will create a 32 character hex-string:</p>
<p><code class="codecolorer text default"><span class="text">dd if=/dev/random bs=1 count=32 2&gt;/dev/null | xxd -ps</span></code></p>
<p>Line 9 and 10 are specifying IKE phase 2. Line 9 creates an IPSec transform-set called hostb-transform (this can be any string you like) and i chose to use esp-3des and esp-sha-hmac for this transform-set. Line 10 is an important one, you can setup an IPSec tunnel in 2 modes: tunnel-mode or transport-mode. In transport mode only the payload is encrypted, in tunnel-mode the ip-header will also be encrypted. At first I didn&#8217;t specify any here. It took me a day figuring out why my IPSec tunnel wouldn&#8217;t work.</p>
<p>Next up are lines 12 &#8211; 16 defining the crypto map. A crypto map is needed for several reasons. Amongst others it&#8217;s used to specify which traffic should be protected by IPSec, which transform sets are to be used with the protected traffic and defining the peers. One could say the crypto map is the glue between different aspects of setting up an IPSec link.</p>
<p>First on line 12 we define the crypto map itself with in my case the name &#8220;hostb-cryptomap&#8221; a sequence number of 1 and we specify it should be an IPSec with ISAKMP crypto. You could also use IPSec with manual keying but that&#8217;s outside the scope of this post.</p>
<p>On line 13 we define our peer, which in my case is the Debian box with ip 10.20.30.42.</p>
<p>On line 14 we tell the crypto map to use the transform set we created on lines 9 and 10.</p>
<p>Line 15 could probably be left out but it never hurts to specify it once more. It tells it still wants to use a 1024 bit Diffie-Hellman encryption only this time it applies to phase 2 instead of phase 1. You could use Diffie-Hellman group 2 in phase 1 and group 5 in phase 2 if you deem it&#8217;s necessary. For now we keep things simple and use group 2 in both phases.</p>
<p>Line 16 is the last line in our crypto map definition and specifies the access list it should use to determine which traffic should be encrypted using IPSec. I&#8217;ll explain the ACL in a couple of moments.</p>
<p>The next block in the configuration is binding the crypto map to a network interface. In my case this is FastEthernet0/1. Everything is straight forward in this setup the only thing you should add to your network interface is what I&#8217;ve specified on line 22. Line 22 binds the crypto map we&#8217;ve just created to this interface and when traffic from and to our defined peer passes through it knows it should be encrypted. If you forget this part your IPSec tunnel won&#8217;t establish.</p>
<p>And the last step on the Cisco side of this setup is the ACL which is specified on lines 24 and 25. On line 24 you create an extended access-list with the name &#8220;hostb-list&#8221; which we&#8217;ve said we want to use in the crypto map. And on line 25 we define we want to allow traffic from the Cisco (10.20.30.40) towards the Debian box (10.20.30.42) and because this ACL is connected to the crypto map the traffic is encrypted using IPSec.</p>
<p>This concludes the Cisco side of this setup and now we&#8217;re going to setup ipsec-tools and racoon on the Debian box so the 2 machines can connect and setup IPSec.</p>
<h2>The Linux Side</h2>
<p>I also assume you know your way around a linux machine and how to install and configure one. For IPSec to work you need to install racoon and ipsec-tools and of course you need network connectivity. But that speaks for itself doesn&#8217;t it?</p>
<p>Note: I&#8217;ve used Debian as Linux OS of choice and the paths to config files I name might be different on your OS.</p>
<p>There are 3 files we are going to edit on this machine to setup our IPSec tunnel.</p>
<h3><em>/etc/ipsec-tools.conf</em></h3>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#!/usr/sbin/setkey -f<br />
<br />
flush;<br />
spdflush;<br />
<br />
spdadd 10.20.30.42 10.20.30.40 any -P out ipsec<br />
&nbsp; esp/transport//require;<br />
<br />
spdadd 10.20.30.40 10.20.30.42 any -P in ipsec<br />
&nbsp; esp/transport//require;</div></td></tr></tbody></table></div>
<p>I&#8217;ve stripped te file from comments so it&#8217;s a bit smaller to paste here and explain what it does. This file gets parsed by the program <em>setkey</em> which is in charge of the Security Associations and Security Policies.</p>
<p>The first line in this config is to specify which interpreter is used to parse the file and as I&#8217;ve said <em>setkey</em> is being used for this.</p>
<p>Lines 3 and 4 respectively flush the Security Association Database and the Security Policy Database (SAD and SPD in short). This is to make sure when you change things in this file and setkey parses this file again the possible existing SA&#8217;s and SP&#8217;s will be flushed.</p>
<p>The next lines 6,7 and 9,10 roughly do the same thing as the crypto map and the ACL on the Cisco side are doing. On line 6 you&#8217;re adding an entry into the SPD telling that any traffic originating from 10.20.30.42 (the debian box) towards 10.20.30.40 (the cisco) should be encrypted by IPSec. Line 7 requires it should be using the ESP protocol, that it&#8217;s an IPSec link which operates in transport mode (in tunnel-mode you should specify tunnel instead of transport). The space between the next 2 slashes is omitted because it&#8217;s not necessary in transport mode. In tunnel mode you should specify the source and destination as x.x.x.x-y.y.y.y. And with <em>require</em> you require the IPSec tunnel to be up before traffic is allowed towards the destination host.</p>
<p>Lines 9 and 10 do the same thing as lines 6 and 7 only this time for traffic originating from 10.20.30.40 (the cisco) towards 10.20.30.42 (the debian box).</p>
<h3><em>/etc/racoon/racoon.conf</em></h3>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">path pre_shared_key &quot;/etc/racoon/psk.txt&quot;;<br />
path certificate &quot;/etc/racoon/certs&quot;;<br />
<br />
remote 10.20.30.40 {<br />
&nbsp; &nbsp; exchange_mode main;<br />
&nbsp; &nbsp; lifetime time 1 hour;<br />
&nbsp; &nbsp; proposal {<br />
&nbsp; &nbsp; &nbsp; &nbsp; encryption_algorithm 3des;<br />
&nbsp; &nbsp; &nbsp; &nbsp; hash_algorithm sha1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; authentication_method pre_shared_key;<br />
&nbsp; &nbsp; &nbsp; &nbsp; dh_group 2;<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
sainfo anonymous<br />
{<br />
&nbsp; &nbsp; pfs_group 2;<br />
&nbsp; &nbsp; lifetime time 1 hour;<br />
&nbsp; &nbsp; encryption_algorithm 3des;<br />
&nbsp; &nbsp; authentication_algorithm hmac_sha1;<br />
&nbsp; &nbsp; compression_algorithm deflate;<br />
}</div></td></tr></tbody></table></div>
<p>Now that we&#8217;ve created our security policies specifying what traffic should be encrypted, it&#8217;s time to create the config for <em>racoon</em>, the daemon which actually provides the IPSec link.</p>
<p>Above you see the contents from <em>racoon.conf</em> which has also been stripped of it&#8217;s comments. The first 2 lines are basic setup for racoon. As with cisco, when using PSK authentication, the PSK needs to be stored somewhere. On line 1 one can specify in which file the PSK&#8217;s are stored. In this case: <em>/etc/racoon/psk.txt </em>we&#8217;ll get to this file later on.</p>
<p>If you would be using certificate based authentication, which we aren&#8217;t in this example, you need to specify the path were certificates are being stored. This is what line 2 does.</p>
<p>Next up is the IKE phase 1 configuration like we did on the cisco. Starting on line 4 where we specify the ip-address of the remote host which in this case is 10.20.30.40 (the cisco).</p>
<p>Line 5 sets the exchange_mode which is used when starting the buildup of an IPSec tunnel. Usually main or aggressive is used. When using main mode like in this example there are 3 two-way exchanges between the initiator and receiver to establish, verify and secure communications. With aggressive mode there are fewer exchanges and almost all information is squeezed into one packet. Aggressive mode is a bit faster setting up the tunnel it is also less secure than main mode. Because when using aggressive mode both sides have exchanged information before there&#8217;s a secure channel and therefore it&#8217;s possible to sniff the line and discover who formed the new Security Association. In this example we&#8217;ll be using main mode as the exchange mode.</p>
<p>If you&#8217;re interested in the specifics of these exchange modes you can search for &#8220;ipsec exchange mode&#8221; on the internet. It is outside the scope of this post to go deeper into this subject.</p>
<p>Next, on line 6, we specify the lifetime of the IKE SA. An SA should not last indefinitely, in this example we give the IKE SA a lifetime of 1 hour which starts running the moment the SA is established. One minute before expiring the system renegotiates the SA and new key material is exchanged. Because the system does this before the SA has expired the user won&#8217;t notice a thing and is able to continue his work and communications with the remote side without interruptions.</p>
<p>Lines 7 through 12 specify the phase 1 policy like we did with the &#8220;crypto isakmp policy 1&#8243; on the cisco. Everything defined in these lines is the same on the cisco because the has to be a matching policy.</p>
<p>Lines 15 through 22 define the phase 2 part of the IPSec setup. First we keep maintaining a Perfect Forward Secrecy Group 2 (remember the Diffie-Hellman comments earlier in this story?) on line 17. Next we also set a lifetime for the phase 2 SA on line 18 like we did a couple of moments ago for phase 1.</p>
<p>Line 19 and 20 will look a bit similar to the transform set we&#8217;ve created on the cisco. This is also what these lines represent. Needless to say they need to be the same on both sides. You&#8217;ll probably noticed that on the cisco we specified esp-3des and esp-sha-hmac and now in racoon we only specify 3des and sha-hmac. Well you&#8217;ve noticed correctly but if you look at <em>ipsec-tools.conf</em> we specified that communications require esp and when you match those up you&#8217;ve got esp-3des and esp-sha-hmac.</p>
<p>Last thing in this file is the compression_algorithm on line 21. Racoon requires this line to be present even if you&#8217;re not using compression. As far as I know &#8220;deflate&#8221; is also the only option possible at this moment, so just put it in there and forget about it.</p>
<h3><em>/etc/racoon/psk.txt</em></h3>
<p>the last step we haven&#8217;t completed, but mentioned before, is the PSK. So fire up your favorite text-editor one more time (my favorite is vim <img src='http://blog.ar-ix.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ) and edit this file.</p>
<p>Since we have only one IPSec tunnel setup this file needs one line containing the ip of the remote host and the PSK so for this example it should contain:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">10.20.30.40 YOURKEY</div></div>
<h2>Finished!</h2>
<p>If you&#8217;ve followed my instructions correctly you should be finished now. Try pinging the cisco (10.20.30.40) from the Debian box for example. It should start responding within a couple of seconds because it needs to setup the tunnel first. Also the ping times are a little higher than a direct link without IPSec because traffic has to be encrypted. In my case (I&#8217;ve used a crosscable between the cisco and debian box) my pingtimes were 2ms slower than without IPSec.</p>
<p>You should check if your IPSec link really got up by tailing <em>/var/log/daemon.log</em> on your debian box and check if you see messages from racoon passing by. This is also a very useful file if things don&#8217;t work, it tells you what might be wrong and on which IKE phase things are failing.</p>
<p>The same can be accomplished on the cisco by using one or more of these commands:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># enable IKE debugging<br />
debug crypto isakmp<br />
<br />
# enable IPSec debugging<br />
debug crypto ipsec<br />
<br />
# disable all debugging<br />
no debug all</div></div>
<p>And last but not least to check if your traffic really gets encrypted fire up a tshark session on debian box monitoring the network interface you used to setup the IPSec link.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">tshark -i eth0</div></div>
<p>Of course you need to install tshark and replace eth0 by the network interface you used. If you&#8217;ll open up a ping to the remote host you should see ESP packets passing by.</p>
<p>I hope this was a useful howto and gave you a little more understanding in the world of IPSec. I know it worked for me, first figuring out and setting up the IPSec link but also whilst writing this post i got a greater understanding in how things work and why certain things are needed.</p>
<p>Please leave a comment if this has helped you or if you found mistakes or just because the fun of it <img src='http://blog.ar-ix.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Kind regards and see you in part 2,</p>
<p>Lammert</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ar-ix.net/archives/29/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updates</title>
		<link>http://blog.ar-ix.net/archives/23</link>
		<comments>http://blog.ar-ix.net/archives/23#comments</comments>
		<pubDate>Tue, 19 Oct 2010 21:18:25 +0000</pubDate>
		<dc:creator>Lammert Hellinga</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[social networking]]></category>
		<category><![CDATA[updates]]></category>

		<guid isPermaLink="false">http://blog.ar-ix.net/?p=23</guid>
		<description><![CDATA[This evening the brand new website of my employer went live (click here if you&#8217;re interested). I thought to be nice to perform an update on my personal site, which you&#8217;re reading right now, obviously What is updated you might &#8230; <a href="http://blog.ar-ix.net/archives/23">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This evening the brand new website of my employer went live (click <a href="http://www.bntnederland.nl" target="_blank">here</a> if you&#8217;re interested).</p>
<p>I thought to be nice to perform an update on my personal site, which you&#8217;re reading right now, obviously <img src='http://blog.ar-ix.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>What is updated you might ask&#8230; well: i&#8217;ve updated my &#8220;About Me&#8221; page with my newly created linkedIn profile. I&#8217;ve added the &#8220;follow me&#8221; button on the left of this site with links to my twitter and my linkedIn profiles. And i added this post <img src='http://blog.ar-ix.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>So what&#8217;s been happening lately in my life&#8230; about 2 months ago i &#8220;finally&#8221; graduated i am now &#8220;Bachelor of Engineering&#8221;. In less than a week i&#8217;ve got a full-time job at my employer. I must say it&#8217;s a lot of weight of off my shoulders, no fuss about graduating anymore. Just working full-time and having fun in my weekends, i&#8217;m loving it.<span id="more-23"></span></p>
<p>At home i have a lot of things which keep me busy, i&#8217;m having trouble deciding what to do first <img src='http://blog.ar-ix.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  A couple of weeks ago i started a new project called [R4CK]. You can read all about it on the <a href="http://www.r4ck.net" target="_blank">website</a>. But don&#8217;t expect it to be finished anytime soon because at this point my network is consuming a lot of my time.</p>
<p>Last week i ordered and received a Cisco 7940 IP Phone. A great toy to play with, i hooked it up with my Asterisk setup and i&#8217;m able to place and receive calls with it. But there&#8217;s so much more, for example the address-book which the phone is able to access. I figured i want to do this with LDAP but i want to have the LDAP server running at one of my vps&#8217;es and not at home where my phone is.</p>
<p>So i&#8217;ve decided i also need a site-to-site vpn tunnel towards my vps&#8217;es (this has been a wish of me for a longer time) but i would like to create my vpn tunnels over IPv6. And since a short time my provider (xs4all) supports native IPv6 to my home (the first provider to do this in the world i&#8217;ve been told). But to use this i needed IOS 12.4 on my router, before i could run this new version i needed to upgrade the memory.</p>
<p>Last week i received and installed this memory and i now have native IPv6 at home \o/ but this week i discovered it wasn&#8217;t enough for IPv6 vpn tunnels, i need a 12.4T image for that and if i want to run that i need more flash memory, more ram and another bootrom in my router so i&#8217;ve accepted this won&#8217;t be happening. So now i&#8217;m at the point i&#8217;m about to configure vpn tunnels and BGP over IPv4.</p>
<p>Once that&#8217;s complete i can focus on LDAP and then back to configuring my phone (which it all started with). On top of that, the server of a friend of mine crashed last week so i&#8217;ve also been busy configuring his new VPS.</p>
<p>So you can imagine don&#8217;t know what to do first and last. Luckily i have some days off next week maybe i can finish some of the tasks mentioned above <img src='http://blog.ar-ix.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  And maybe i have some time to read in my new book which i ordered last week (<a href="http://www.ciscopress.com/bookstore/product.asp?isbn=1587054647" target="_blank">link</a>) it should arrive this week.</p>
<p>Until the next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ar-ix.net/archives/23/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python and net-snmp</title>
		<link>http://blog.ar-ix.net/archives/9</link>
		<comments>http://blog.ar-ix.net/archives/9#comments</comments>
		<pubDate>Thu, 08 Jul 2010 21:26:37 +0000</pubDate>
		<dc:creator>Lammert Hellinga</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[snmp]]></category>

		<guid isPermaLink="false">http://blog.ar-ix.net/?p=9</guid>
		<description><![CDATA[Some of you may know that i have a 19&#8243; rack at home with some interesting hardware in it. Some of this hardware also provides a couple of hundreds of gigabytes of storage. But that system takes about 3 maybe &#8230; <a href="http://blog.ar-ix.net/archives/9">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some of you may know that i have a 19&#8243; rack at home with some interesting hardware in it. Some of this hardware also provides a couple of hundreds of gigabytes of storage. But that system takes about 3 maybe 4 amps when it&#8217;s idling. Taken into account that 1 amp 24/7 costs me about 20 euros per month. So you can imagine that i don&#8217;t have all my equipment running 24/7.</p>
<p>Once in a while i use this system to put some files onto it and then i turn it off again. To be able to also do this remote i&#8217;ve bought myself an APC PDU (model AP9212) a couple of months ago. Since that time i always had an idea to automate a backup job which would perform the following steps for me:</p>
<ol>
<li>Turn on my storage system</li>
<li>Mount the backup share</li>
<li>Transfer the backup onto the share</li>
<li>Unmount the backup share</li>
<li>Send a shutdown command to my storage system</li>
<li>Turn of my storage system</li>
</ol>
<p>The day before yesterday i finally put my hands on this idea and started looking how i could get and set data to and from my PDU using SNMP. A while ago i already figured out the specific OID&#8217;s needed for this job.<br />
<span id="more-9"></span></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.1.3.6.1.4.1.318.1.1.4.4.2.1.4.1 for the name of the first outlet (change the last digit to the corresponding port)<br />
<br />
and<br />
<br />
.1.3.6.1.4.1.318.1.1.4.4.2.1.3.1 for the status of the first outlet (change the last digit to the corresponding port)</div></div>
<p>So i started searching and reading and found that the net-snmp package comes with python bindings. The small example for an snmpget looked simple enough so i started programming. Within the hour i had written a small script that reads the names and statuses of all 8 ports. (see example code at the bottom of this post)</p>
<p>Unfortunately my hopes were up and this was all the easy part and i was stupid enough to think that an snmpset wouldn&#8217;t be much harder, ok in the end maybe it wasn&#8217;t but getting there&#8230;..</p>
<p>Documentation for the net-snmp python bindings isn&#8217;t widely available i discovered you pretty much have to rely on the README provided with the net-snmp package. Searching for code examples is a quest without suitable results (it returns a lot of snmpget examples which i didn&#8217;t need).</p>
<p>And while trying different ways to get my code working and actually controlling a port on my PDU did take me several hours. I ran into all sorts of errors for example when i used the following piece of code trying to get it to work:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">infovar <span style="color: #66cc66;">=</span> netsnmp.<span style="color: black;">Varbind</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;.1.3.6.1.4.1.318.1.1.4.4.2.1.3.5&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;1&quot;</span><span style="color: black;">&#41;</span><br />
netsnmp.<span style="color: black;">snmpset</span><span style="color: black;">&#40;</span>infovar<span style="color: #66cc66;">,</span> Version <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span> DestHost<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'192.168.2.3'</span><span style="color: #66cc66;">,</span> Community<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'writecommunity'</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>i got this error:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">error: set: no type found for objectNone</div></div>
<p>ok so diving into the README once again i changed the first line to:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">infovar <span style="color: #66cc66;">=</span> netsnmp.<span style="color: black;">Varbind</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;.1.3.6.1.4.1.318.1.1.4.4.2.1.3.5&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;0&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;1&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;INTEGER&quot;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>now my code actually ran but nothing happened on my PDU&#8230; i thought. I started inspecting my network traffic because i was curious what actually was being sent to my PDU.  I made a pcap file with tcpdump and inspected it with wireshark and that showed me the response from the PDU:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">error-status: noSuchName (2)</div></div>
<p>Ok, so it was clear that somehow snmp couldn&#8217;t find this OID and wasn&#8217;t able to write a value to it. But how is that possible? i&#8217;m certain that my OID is right. So a lot of trying, searching, cursing and more cursing later i started digging in the net-snmp package.</p>
<p>In this package i found a unittest for the python snmp bindings so i&#8217;ve decided to enable the snmp daemon on my server and run this unittest and to my big suprise this worked including the snmpset method. And when i dug through the unittest code i found nothing really different from my code.</p>
<p>After careful reading the code over and over again i suddenly realised that they put a value in sysDescription.0 but their varbind looked like this:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">netsnmp.<span style="color: black;">Varbind</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;sysDescription&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;0&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;a new description&quot;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>and i realised that they split up sysDescription.0 in the varbind call so what if i do the same thing? so i started an snmpwalk to look at the values again and i made my varbind look like this:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">netsnmp.<span style="color: black;">Varbind</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;enterprises&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;318.1.1.4.4.2.1.3.5&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;1&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;INTEGER&quot;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>and when i ran my code again i saw that port 5 which i was testing on suddenly turned on i started cheering because this was the thing i was looking for, my code was working. (i added INTEGER into the call because without it it was still producing an error).</p>
<p>I hope that with this post i save some of you the same trouble i had to undergo. I can now continue writing my backupscript, i can now perform the first and last task now the ones that lie in between <img src='http://blog.ar-ix.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>The SNMP Get example (reading the names and statuses of port 1 through <img src='http://blog.ar-ix.net/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> </p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> netsnmp<br />
<br />
HEADER <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[95m'</span><br />
OKBLUE <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[94m'</span><br />
OKGREEN <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[92m'</span><br />
WARNING <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[93m'</span><br />
FAIL <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[91m'</span><br />
ENDC <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[0m'</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">9</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; info <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;.1.3.6.1.4.1.318.1.1.4.4.2.1.4.%i&quot;</span> % <span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; control <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;.1.3.6.1.4.1.318.1.1.4.4.2.1.3.%i&quot;</span> % <span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; infovar <span style="color: #66cc66;">=</span> netsnmp.<span style="color: black;">Varbind</span><span style="color: black;">&#40;</span>info<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; infores <span style="color: #66cc66;">=</span> netsnmp.<span style="color: black;">snmpget</span><span style="color: black;">&#40;</span>infovar<span style="color: #66cc66;">,</span> Version <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span> DestHost <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'192.168.2.3'</span><span style="color: #66cc66;">,</span> Community<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'readcommunity'</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; controlvar <span style="color: #66cc66;">=</span> netsnmp.<span style="color: black;">Varbind</span><span style="color: black;">&#40;</span>control<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; controlres <span style="color: #66cc66;">=</span> netsnmp.<span style="color: black;">snmpget</span><span style="color: black;">&#40;</span>controlvar<span style="color: #66cc66;">,</span> Version <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span> DestHost <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'192.168.2.3'</span><span style="color: #66cc66;">,</span> Community<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'readcommunity'</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> controlres<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'1'</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> HEADER + infores<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">' ... '</span> + OKGREEN + <span style="color: #483d8b;">'On'</span> + ENDC<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> controlres<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'2'</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> HEADER + infores<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">' ... '</span> + OKBLUE + <span style="color: #483d8b;">'Off'</span> + ENDC<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> controlres<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'3'</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> HEADER + infores<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">' ... '</span> + WARNING + <span style="color: #483d8b;">'Rebooting'</span> + ENDC<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> HEADER + infores<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">' ... '</span> + FAIL + <span style="color: #483d8b;">'Error'</span> + ENDC</div></td></tr></tbody></table></div>
<p>The SNMP set example (setting port 5 to status On)</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> netsnmp<br />
<br />
HEADER <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[95m'</span><br />
OKBLUE <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[94m'</span><br />
OKGREEN <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[92m'</span><br />
WARNING <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[93m'</span><br />
FAIL <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[91m'</span><br />
ENDC <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[0m'</span><br />
<br />
var <span style="color: #66cc66;">=</span> netsnmp.<span style="color: black;">Varbind</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'enterprises'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'318.1.1.4.4.2.1.3.5'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'1'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'INTEGER'</span><span style="color: black;">&#41;</span><br />
res <span style="color: #66cc66;">=</span> netsnmp.<span style="color: black;">snmpset</span><span style="color: black;">&#40;</span>var<span style="color: #66cc66;">,</span> Version <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span> DestHost<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'192.168.2.3'</span><span style="color: #66cc66;">,</span> Community<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'writecommunity'</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>Use code at your own risk, i only posted it to provide an example of how it can be done. Also the ip address of my PDU and community string have been changed, change to your needs if you want to try it. If you have any questions, comments or compliments please leave a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ar-ix.net/archives/9/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Blog Live</title>
		<link>http://blog.ar-ix.net/archives/1</link>
		<comments>http://blog.ar-ix.net/archives/1#comments</comments>
		<pubDate>Wed, 07 Jul 2010 22:00:18 +0000</pubDate>
		<dc:creator>Lammert Hellinga</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.ar-ix.net/?p=1</guid>
		<description><![CDATA[Hi, I&#8217;ve just installed my new blog, soon i will add some posts with things that i come across and/or keep me busy during my daily life]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;ve just installed my new blog, soon i will add some posts with things that i come across and/or keep me busy during my daily life <img src='http://blog.ar-ix.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ar-ix.net/archives/1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

