<?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>108.bz &#187; CLI</title>
	<atom:link href="http://www.108.bz/posts/tag/cli/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.108.bz</link>
	<description>Wandering futilities...</description>
	<lastBuildDate>Fri, 27 May 2011 09:08:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Cloning DHCP reservations between Windows servers</title>
		<link>http://www.108.bz/posts/it/cloning-dhcp-reservations-between-windows-servers/</link>
		<comments>http://www.108.bz/posts/it/cloning-dhcp-reservations-between-windows-servers/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 16:01:30 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=688</guid>
		<description><![CDATA[Quick post to show you how DHCP reservations can be replicated between Windows servers. Why whould you want to do that? Because often, to achieve DHCP service high availability, DHCP scopes are equally divided between servers. When a client PC is connected to the network, it sends out a broadcast to discover which DHCP servers [...]]]></description>
			<content:encoded><![CDATA[<p>Quick post to show you how DHCP reservations can be replicated between Windows servers. Why whould you want to do that? Because often, to achieve DHCP service high availability, DHCP scopes are equally divided between servers. When a client PC is connected to the network, it sends out a broadcast to discover which DHCP servers are active on that particular ethernet segment. Depending on their number, the PC will receive one or more answer, each offering an IP address. If a client is to be assigned a fixed IP, all of those offers should bear the same IP address. Hence, DHCP reservations need to be configured the same for every DHCP server in the given scope. As far as I know, this needs to be done by hand. To speed up the process, I use <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">netsh</span> (see <a href="http://technet.microsoft.com/en-us/library/cc787375(WS.10).aspx">Netsh commands for DHCP</a>).</p>
<p>The command below will dump all of the reservations to a file named &#8220;reservations.txt&#8221;. <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">findstr</span> filters <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">netsh</span> output keeping just the info we need.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Documents and Settings\Administrator&gt; netsh dhcp server \\dhcpsrv1 scope 10.4.0.0 dump | findstr Add.reservedip &gt; reservations.txt</div></div>
<p>Each line in &#8220;reservations.txt&#8221; should look like this:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Dhcp Server 10.4.1.1 Scope 10.4.0.0 Add reservedip 10.4.5.3 58b04576339a &quot;pcname.domain.lan&quot; &quot;Reservation Comment&quot; &quot;BOTH&quot;</div></div>
<p><span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">10.4.1.1</span> is the IP address for <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dhcpsrv1</span>, the &#8220;source&#8221; DHCP server.</p>
<p>Open &#8220;reservations.txt&#8221; in a text editor, check that everything is fine and substitute the source DHCP server IP with the target&#8217;s one (i.e.: 10.4.1.1 becomes 10.4.1.2), save the file and run:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Documents and Settings\Administrator&gt; netsh &lt; reservations.txt<br />
netsh&gt;<br />
Changed the current scope context to 10.4.0.0 scope.<br />
<br />
Command completed successfully.<br />
netsh&gt;<br />
Command completed successfully.<br />
netsh&gt;<br />
[..]</div></div>
<p>That&#8217;s it; not a fancy trick, but it may be useful nonetheless. Just beware that, when there are thousands of clients, <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">netsh</span> could take a while to complete its job (especially the &#8220;dump&#8221; step)&#8230;</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=688" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/cloning-dhcp-reservations-between-windows-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript for Sysadmins, again</title>
		<link>http://www.108.bz/posts/it/javascript-for-sysadmins-again/</link>
		<comments>http://www.108.bz/posts/it/javascript-for-sysadmins-again/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 21:09:50 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[SonicWALL]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=678</guid>
		<description><![CDATA[Following up on the previous post, let me show you other ways to trick web application into doing what they&#8217;ve not been designed to do: saving the Sysadmin some typing and avoding errors. I&#8217;ll use JavaScript, jQuery, Greasemonkey and Perl to automate Firefox and implement a sort of dynamic form filling. Let&#8217;s start with a [...]]]></description>
			<content:encoded><![CDATA[<p>Following up on the <a href="http://www.108.bz/posts/it/firequery-fun/">previous post</a>, let me show you other ways to trick web application into doing what they&#8217;ve not been designed to do: saving the Sysadmin some typing and avoding errors. I&#8217;ll use JavaScript, jQuery, Greasemonkey and Perl to automate Firefox and implement a sort of dynamic form filling. Let&#8217;s start with a screencast:</p>
<p><iframe title="YouTube video player" width="600" height="474" src="http://www.youtube.com/embed/vO55CBFZwq8?hd=1" frameborder="0" allowfullscreen></iframe></p>
<p>The config I had to do (on a <a href="http://www.sonicwall.com">SonicWALL</a> firewall), involves about 70 subnets, each similar to the other. Only the subnet&#8217;s addressing scheme changes, making creation of VLANs/objects/rules a repetitive and error-prone task.</p>
<p>What&#8217;s happening in the screencast? VLAN sub-interfaces are being automatically created without me having to type anything at all. How could that be? A simple Greasemonkey script calls a &#8220;web service&#8221; (AJAX style) fetching the needed data and filling the form for me (I just click the &#8220;OK&#8221; or &#8220;Cancel&#8221; buttons). Why this whole Greasemonkey/web service mess? Because here, as in the previous post, JavaScript code is basically being injected into a &#8220;page&#8221;. Pages (or tabs, or windows) are ran by the browser into a <a href="http://en.wikipedia.org/wiki/Sandbox_(software_development)">sandbox</a>: they can&#8217;t exchange data between each other. Thus page A (the webapp) can&#8217;t access code/data in page B (our code). Moreover, injected JavaScript gets lost when the page is closed (think ugly GUIs where dialog windows pop up just to be destroyed shortly after). We need a way (Greasemonkey) to re-inject the code each time our page is shown and some external, long lived, entity to update/keep status (the web service).</p>
<p>Thanks to the <a href="http://search.cpan.org/~jesse/HTTP-Server-Simple-0.43/lib/HTTP/Server/Simple.pm">HTTP::Server::Simple</a> Perl module, building the web service is trivial. The only logic behind it is keeping track of the current VLAN&#8217;s index, iterating through each value on subsequent web service calls:</p>
<div class="codecolorer-container perl blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span><br />
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/package.html"><span style="color: #000066;">package</span></a> LameServer<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> base <a href="http://perldoc.perl.org/functions/qw.html"><span style="color: #000066;">qw</span></a><span style="color: #009900;">&#40;</span>HTTP<span style="color: #339933;">::</span><span style="color: #006600;">Server</span><span style="color: #339933;">::</span><span style="color: #006600;">Simple</span><span style="color: #339933;">::</span><span style="color: #006600;">CGI</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@VLANS</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/qw.html"><span style="color: #000066;">qw</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span> <span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">12</span> <span style="color: #cc66cc;">13</span> <span style="color: #cc66cc;">14</span> <span style="color: #cc66cc;">15</span> <span style="color: #cc66cc;">16</span> <span style="color: #cc66cc;">17</span> <span style="color: #cc66cc;">18</span> <span style="color: #cc66cc;">19</span> <span style="color: #cc66cc;">20</span> <span style="color: #cc66cc;">21</span> <span style="color: #cc66cc;">22</span> <span style="color: #cc66cc;">23</span> <span style="color: #cc66cc;">24</span> <span style="color: #cc66cc;">25</span> <span style="color: #cc66cc;">26</span> <span style="color: #cc66cc;">27</span> <span style="color: #cc66cc;">28</span> <span style="color: #cc66cc;">29</span> <span style="color: #cc66cc;">30</span> <span style="color: #cc66cc;">31</span> <span style="color: #cc66cc;">32</span> <span style="color: #cc66cc;">33</span> <span style="color: #cc66cc;">34</span> <span style="color: #cc66cc;">35</span> <span style="color: #cc66cc;">36</span> <span style="color: #cc66cc;">37</span> <span style="color: #cc66cc;">38</span> <span style="color: #cc66cc;">39</span> <span style="color: #cc66cc;">40</span> <span style="color: #cc66cc;">41</span> <span style="color: #cc66cc;">42</span> <span style="color: #cc66cc;">43</span> <span style="color: #cc66cc;">44</span> <span style="color: #cc66cc;">45</span> <span style="color: #cc66cc;">46</span> <span style="color: #cc66cc;">61</span> <span style="color: #cc66cc;">62</span> <span style="color: #cc66cc;">63</span> <span style="color: #cc66cc;">64</span> <span style="color: #cc66cc;">65</span> <span style="color: #cc66cc;">66</span> <span style="color: #cc66cc;">67</span> <span style="color: #cc66cc;">68</span> <span style="color: #cc66cc;">69</span> <span style="color: #cc66cc;">70</span> <span style="color: #cc66cc;">71</span> <span style="color: #cc66cc;">72</span> <span style="color: #cc66cc;">73</span> <span style="color: #cc66cc;">74</span> <span style="color: #cc66cc;">75</span> <span style="color: #cc66cc;">76</span> <span style="color: #cc66cc;">77</span> <span style="color: #cc66cc;">78</span> <span style="color: #cc66cc;">79</span> <span style="color: #cc66cc;">84</span> <span style="color: #cc66cc;">85</span> <span style="color: #cc66cc;">86</span> <span style="color: #cc66cc;">87</span> <span style="color: #cc66cc;">88</span> <span style="color: #cc66cc;">89</span> <span style="color: #cc66cc;">90</span> <span style="color: #cc66cc;">91</span> <span style="color: #cc66cc;">92</span> <span style="color: #cc66cc;">93</span> <span style="color: #cc66cc;">94</span> <span style="color: #cc66cc;">95</span> <span style="color: #cc66cc;">96</span> <span style="color: #cc66cc;">97</span> <span style="color: #cc66cc;">98</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$COUNTER</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">sub</span> handle_request <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$self</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$cgi</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;HTTP/1.0 200 OK<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Content-type:text/plain<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #000000; font-weight: bold;">STDERR</span> <span style="color: #ff0000;">&quot;$VLANS[$COUNTER] index $COUNTER<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">$VLANS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$COUNTER</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$COUNTER</span><span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$COUNTER</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$COUNTER</span> <span style="color: #339933;">&gt;=</span> <span style="color: #0000ff;">@VLANS</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<br />
<a href="http://perldoc.perl.org/functions/package.html"><span style="color: #000066;">package</span></a> main<span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$server</span> <span style="color: #339933;">=</span> LameServer<span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3333</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #0000ff;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>And here&#8217;s the Greasemonkey script. It runs automatically when the &#8220;add VLAN&#8221; page pops up, does the sort-of-AJAX call, uses jQuery to properly fill the form.</p>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">// ==UserScript==</span><br />
<span style="color: #006600; font-style: italic;">// @name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CurrentVLAN</span><br />
<span style="color: #006600; font-style: italic;">// @namespace &nbsp; &nbsp; &nbsp;dontcare</span><br />
<span style="color: #006600; font-style: italic;">// @require &nbsp; &nbsp; &nbsp; &nbsp;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js</span><br />
<span style="color: #006600; font-style: italic;">// @include &nbsp; &nbsp; &nbsp; &nbsp;https://192.168.168.168/*</span><br />
<span style="color: #006600; font-style: italic;">// ==/UserScript==</span><br />
<br />
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/192.168.168.168.*editInterface/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; GM_xmlhttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; method<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://localhost:3333/&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">onload</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window.<span style="color: #660066;">GM_CurrentVLAN</span> <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>response.<span style="color: #660066;">responseText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GM_log<span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">GM_CurrentVLAN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> GM_wait<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> unsafeWindow.<span style="color: #660066;">jQuery</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span>GM_wait<span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ <span style="color: #339933;">=</span> unsafeWindow.<span style="color: #660066;">jQuery</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; GM_wait<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; window.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select[name=interface_Zone]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'CZ'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unsafeWindow.<span style="color: #660066;">setIfaceContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// &quot;Zone&quot; onchange function.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[name=iface_vlan_tag]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">GM_CurrentVLAN</span><span style="color: #339933;">+</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select[name=iface_vlan_parent]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'X0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[name=lan_iface_lan_ip]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;10.0.&quot;</span><span style="color: #339933;">+</span>window.<span style="color: #660066;">GM_CurrentVLAN</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[name=lan_iface_ping_mgmt]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
<span style="color: #009900;">&#125;</span></div></div>
<p>I built similar scripts to create static ARP entries and routes. Another one took care of firewall symbolic objects (names) but, as that part of the config is itself carried out by AJAX (in a non reloading window), I didn&#8217;t need Greasemonkey, just Firebug.<br />
No kidding, the above tricks saved me half a day of tedium&#8230;</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=678" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/javascript-for-sysadmins-again/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FireQuery fun</title>
		<link>http://www.108.bz/posts/it/firequery-fun/</link>
		<comments>http://www.108.bz/posts/it/firequery-fun/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 22:09:44 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Aventail]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[SonicWALL]]></category>
		<category><![CDATA[SSLVPN]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=666</guid>
		<description><![CDATA[Or how to toggle a thousand checkboxes clicking none. Have you ever wondered that jQuery may be relevant to your everyday sysadmin job? It is: web-based GUIs proliferate and the Command Line is sooo nineties (this one&#8217;s not mine)&#8230; Working on a SonicWALL/Aventail SSL VPN box, I was asked to simplify how permissions were mapped [...]]]></description>
			<content:encoded><![CDATA[<p>Or how to toggle a thousand checkboxes clicking none.<br />
Have you ever wondered that jQuery may be relevant to your everyday sysadmin job? It is: web-based GUIs proliferate and the Command Line is sooo nineties (this one&#8217;s not mine)&#8230;<br />
Working on a SonicWALL/Aventail SSL VPN box, I was asked to simplify how permissions were mapped to Users. What a User could or couldn&#8217;t do, was defined at the User level. Ok, let&#8217;s just:</p>
<ul>
<li>Create an A/D group for each role/profile.</li>
<li>Configure permissions (rules, resources access, &#8230;) on various <i>Communities</i> (Aventail parlance for roles/profiles).</li>
<li>Put the right Users into the right A/D group.</li>
<li>Cleanup: generally, each Community should just have A/D groups assigned to it. Get rid of unnecessary Community memberships.</li>
</ul>
<p>First three tasks were easy (thanks also to the <a href="http://www.108.bz/posts/it/cloning-an-active-directory-group/">DS*</a> commands). The fourth, uhm:<br />
<a href="http://www.108.bz/wp-content/uploads/2011/03/20110118-sonicwallaventail1.png"><img src="http://www.108.bz/wp-content/uploads/2011/03/20110118-sonicwallaventail1.png" alt="" title="sonicwallaventail" width="550" height="631" class="aligncenter size-full wp-image-669" /></a><br />
Removing members from a Community means unchecking each User. In my case, more than one thousand clicks and a beginning of carpal tunnel syndrome. At page three I started to think about a less saddening way.</p>
<p><a href="http://firequery.binaryage.com/">FireQuery</a> is a Firefox extensions that let&#8217;s you &#8220;inject&#8221; jQuery into any webpage. Here&#8217;s what I did:</p>
<ul>
<li>Went to the page depicted above (the one that let&#8217;s you assign members to a Community).</li>
<li>Launched Firebug.</li>
<li>Inspected the DOM and noticed that each of the checkboxes value begins with &#8220;AV&#8221;.</li>
<li>Used the debugger to see what&#8217;s going on when checking/unchecking members. Nothing really strange: just a bit of JavaScript to highlight a row depending on its checkbox&#8217;s status.</li>
<li>Hit the <i>jQuerify</i> button. FireQuery is needed because Aventail&#8217;s web-based GUI doesn&#8217;t use jQuery.</li>
<li>Went to <i>Console</i>, typed the JavaScript one-liner below and hit <i>Run</i></li>
</ul>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[value^=&quot;AV&quot;]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span></div></div>
<p>which translates to: use jQuery to select all of the checkboxes whose value starts with &#8220;AV&#8221;. Uncheck the selected checkboxes.</p>
<p>See? No useless clicking: a GUI has been CLI-fied.</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=666" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/firequery-fun/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using the CLI to manage Windows DNS servers</title>
		<link>http://www.108.bz/posts/uncategorized/using-the-cli-to-manage-windows-dns-servers/</link>
		<comments>http://www.108.bz/posts/uncategorized/using-the-cli-to-manage-windows-dns-servers/#comments</comments>
		<pubDate>Mon, 24 May 2010 14:16:46 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=486</guid>
		<description><![CDATA[(This, for once, is going to be quick.) Did you know about the Dnscmd.exe command? Read about it here and here. It&#8217;s the command-line/DOS prompt way to configure Microsoft&#8217;s DNS servers&#8230; If you need to create many zones/records at once, it saves you lots of clicks. Here&#8217;s how to add six DNS zones (same domain [...]]]></description>
			<content:encoded><![CDATA[<p>(This, for once, is going to be quick.)<br />
Did you know about the <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Dnscmd.exe</span> command? Read about it <a href="http://technet.microsoft.com/en-us/library/cc778513(WS.10).aspx">here</a> and <a href="http://www.petri.co.il/dnscmd_command_in_windows_2000_2003.htm">here</a>. It&#8217;s the command-line/DOS prompt way to configure Microsoft&#8217;s DNS servers&#8230; If you need to create many zones/records at once, it saves you lots of clicks.<br />
Here&#8217;s how to add six DNS zones (same domain name, different TLD). With the <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">/DSPrimary</span> option, the zone will be stored into Active Directory (rather than a file).</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dnscmd /ZoneAdd domainname.bz &nbsp;/DSPrimary<br />
dnscmd /ZoneAdd domainname.biz /DSPrimary<br />
dnscmd /ZoneAdd domainname.com /DSPrimary<br />
dnscmd /ZoneAdd domainname.eu &nbsp;/DSPrimary<br />
dnscmd /ZoneAdd domainname.net /DSPrimary<br />
dnscmd /ZoneAdd domainname.org /DSPrimary</div></div>
<p>And here&#8217;s how to add the same &#8220;A&#8221; record (named &#8220;www&#8221;) to each of the zones created above.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dnscmd dns-dc-hostname /RecordAdd domainname.bz &nbsp;www A 10.0.0.123<br />
dnscmd dns-dc-hostname /RecordAdd domainname.biz www A 10.0.0.123<br />
dnscmd dns-dc-hostname /RecordAdd domainname.com www A 10.0.0.123<br />
dnscmd dns-dc-hostname /RecordAdd domainname.eu &nbsp;www A 10.0.0.123<br />
dnscmd dns-dc-hostname /RecordAdd domainname.net www A 10.0.0.123<br />
dnscmd dns-dc-hostname /RecordAdd domainname.org www A 10.0.0.123</div></div>
<p>As you may have guessed this is the typical scenario where you&#8217;ve got to re-create some external zones, on the internal DNS servers. That&#8217;s needed in order for the internal hosts to reach some server with the &#8220;public&#8221; DNS name, but the private IP.<br />
For the sake of completeness, let me also mention that you could achieve the same effect by leaving DNS as it is, and configuring  &#8220;loopback NAT&#8221;/&#8221;double NAT&#8221; on the router/firewall. E.g.: an internal Host wants to reach an internal Server, given it&#8217;s public hostname, mapped to a public IP address. It asks the (possibly internal) DNS to translate the name. DNS doesn&#8217;t know the zone, it forwards the query to an external DNS Server, obtaining a public IP address that it hands back to the Client. Since its address is non-local, while trying to talk with the Server, the Client sends packets to its default gateway (possibly the router/firewall). The firewall matches the server&#8217;s public IP addresses, substituting it with the right private one. It also changes the source IP, swapping the Client&#8217;s with the firewall&#8217;s LAN address. This way Client and Server are actually communicating <i>through</i> the firewall, even if they&#8217;re both internal hosts. And the Server can&#8217;t tell Client A from Client B since every connection to it comes from the firewall&#8217;s IP address. That&#8217;s the main reason why I prefer duplicating the public DNS zones on internal DNS servers, with private IP addresses: you avoid routing internal traffic through the firewall, and avoid NAT where there shouldn&#8217;t be any.</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=486" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/uncategorized/using-the-cli-to-manage-windows-dns-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

