<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4963340397675513437</id><updated>2012-01-25T12:24:18.900-08:00</updated><category term='Python'/><category term='scripting'/><category term='dns'/><category term='networking'/><title type='text'>Gunni M</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gunnim.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4963340397675513437/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://gunnim.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Gunni M</name><uri>http://www.blogger.com/profile/01904429404624066667</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4963340397675513437.post-4825105589853901527</id><published>2009-09-09T13:52:00.000-07:00</published><updated>2009-11-07T05:18:40.186-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><category scheme='http://www.blogger.com/atom/ns#' term='networking'/><title type='text'>New links, new version and additions</title><content type='html'>Alright, so it seems inetpro.org is down atm and i'm not even sure they still have my scripts hosted so here are new links, new version and additions to my python network management scripts. I'm now using the excellent pexpect in most of them which you can grab from here:&lt;br /&gt;&lt;div&gt;&lt;a href="http://sourceforge.net/projects/pexpect/" style="text-decoration: none;"&gt;http://sourceforge.net/projects/pexpect/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;rix.is ip filter:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Edit the list from rix.is for an ASA object-group&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;http://dl.getdropbox.com/u/66544/scripts/edit-rix-ipv4-is.py&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Send the edited list to the ASA&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;http://dl.getdropbox.com/u/66544/scripts/update-ASA.py&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Icelandic whitelisting, much fun ;) the script that started the blog, still brilliant :D&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Configuration Downloader:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;http://dl.getdropbox.com/u/66544/scripts/dl-config.py&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family:-webkit-monospace;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span&gt;&lt;span&gt; In addition to the dl-config.py script you will need a settings file declaring the tftp host  (ASA/PIX don't support scp afaik) and some other variables mentioned in the dl-config.py file  itself. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt; You will need a new-line delimited device list flat file (hostnames/ip addresses, passed as  arguments to ssh) and optionally a telnet device list.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family:-webkit-monospace;font-size:12px;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span&gt;&lt;span&gt; You should use the following lines in your/etc/ssh/ssh_config file if you often add devices and don't want to manually accept the host_keys for each one before running the script: &lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt; Host * &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; StrictHostKeyChecking no&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span"   style="font-family:-webkit-monospace;font-size:100%;"&gt;&lt;span class="Apple-style-span"  style=" white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;font-size:12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;I use this instead of alternatives such as rancid (i'm the only networking guy at my IT firm  anyway so i use this for backups and with dropbox running on the *nix boxes receiving the  configurations i get archives and availability.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;a href="http://wiki.getdropbox.com/TipsAndTricks/TextBasedLinuxInstall"&gt;http://wiki.getdropbox.com/TipsAndTricks/TextBasedLinuxInstall&lt;/a&gt; &lt;- Highly recommmended&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Device Commander:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;http://dl.getdropbox.com/u/66544/scripts/device-commander.py&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; Requirements are mostly the same as for dl-config.py (settings file, device-list and preferably  edit your /etc/ssh/ssh_config file)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;This guys awesome, I use it at one site like a poor mans WLAN-Controller :D&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;just make sure to test the command list out on one device first before you run it against a batch..  and remember "reload in" is your friend! with the inbuilt expect feature of the command sender  you can answer questions from commands such as reload in and copy.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Named master/slave scripted domain additions:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;http://dl.getdropbox.com/u/66544/scripts/domain%20additions%20-%20removals.7z&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;This ones the oldest of my scripts and it shows, it's still using TCL expect and i hardly believe it  works.. :)&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4963340397675513437-4825105589853901527?l=gunnim.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gunnim.blogspot.com/feeds/4825105589853901527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gunnim.blogspot.com/2009/09/new-links-new-version-and-additions.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4963340397675513437/posts/default/4825105589853901527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4963340397675513437/posts/default/4825105589853901527'/><link rel='alternate' type='text/html' href='http://gunnim.blogspot.com/2009/09/new-links-new-version-and-additions.html' title='New links, new version and additions'/><author><name>Gunni M</name><uri>http://www.blogger.com/profile/01904429404624066667</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4963340397675513437.post-8414812407962493512</id><published>2009-05-16T17:17:00.000-07:00</published><updated>2009-05-16T17:24:00.515-07:00</updated><title type='text'>pexpect rocks?</title><content type='html'>So i wrote a simple configuration nabbing script a while ago, using expect and python initially, i rewrote it the other day with pexpect, a python native version of expect. very nice, highly recommended.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://inetpro.org/pastebin/1461/"&gt;http://inetpro.org/pastebin/1461/&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;ofc you'd preferably want to copy your configurations over the internet with scp but the uber secure ASA/PIX platform doesn't support that afaik.. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4963340397675513437-8414812407962493512?l=gunnim.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gunnim.blogspot.com/feeds/8414812407962493512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gunnim.blogspot.com/2009/05/pexpect-rocks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4963340397675513437/posts/default/8414812407962493512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4963340397675513437/posts/default/8414812407962493512'/><link rel='alternate' type='text/html' href='http://gunnim.blogspot.com/2009/05/pexpect-rocks.html' title='pexpect rocks?'/><author><name>Gunni M</name><uri>http://www.blogger.com/profile/01904429404624066667</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4963340397675513437.post-6700007690835348333</id><published>2009-03-16T12:13:00.000-07:00</published><updated>2009-03-16T12:41:20.337-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dns'/><category scheme='http://www.blogger.com/atom/ns#' term='scripting'/><title type='text'>Python+Expect named.conf additions/removals</title><content type='html'>So i was getting tired of manually ssh'ing to the trio of name servers my company runs whenever we needed to add a new domain. I set out to script the process and ended up with this:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Both expect scripts take a single argument, the domain to be added, be sure to modify the host part of the spawn ssh lines to fit your needs.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The expect script run on the master for domain additions&lt;/div&gt;&lt;div&gt;&lt;a href="http://internetworkpro.org/pastebin/1213/"&gt;http://internetworkpro.org/pastebin/1213/&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The Python script run by the expect script on the master:&lt;/div&gt;&lt;div&gt;&lt;a href="http://internetworkpro.org/pastebin/1218/"&gt;http://internetworkpro.org/pastebin/1218/&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;The Python script run by the expect script on the slaves:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://internetworkpro.org/pastebin/1217/"&gt;http://internetworkpro.org/pastebin/1217/&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The expect script run on the master for domain deletions&lt;/div&gt;&lt;div&gt;&lt;a href="http://internetworkpro.org/pastebin/1214/"&gt;http://internetworkpro.org/pastebin/1214/&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The Python script run by the expect script on all servers:&lt;/div&gt;&lt;div&gt;&lt;a href="http://internetworkpro.org/pastebin/1215/"&gt;http://internetworkpro.org/pastebin/1215/&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The expect scripts assume you use public key authentication with ssh.&lt;/div&gt;&lt;div&gt;These are some of my first attempts at python scripting and i'm not a seasoned expect/tcl guy either so if these can't be of any help to anyone maybe i'll receive some constructive criticism instead that can help me!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4963340397675513437-6700007690835348333?l=gunnim.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gunnim.blogspot.com/feeds/6700007690835348333/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gunnim.blogspot.com/2009/03/pythonexpect-namedconf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4963340397675513437/posts/default/6700007690835348333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4963340397675513437/posts/default/6700007690835348333'/><link rel='alternate' type='text/html' href='http://gunnim.blogspot.com/2009/03/pythonexpect-namedconf.html' title='Python+Expect named.conf additions/removals'/><author><name>Gunni M</name><uri>http://www.blogger.com/profile/01904429404624066667</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4963340397675513437.post-419487518342358228</id><published>2009-02-12T06:41:00.001-08:00</published><updated>2009-02-12T07:04:44.469-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='networking'/><title type='text'>Blocking non-icelandic traffic</title><content type='html'>&lt;div&gt;Since IOS 12.4(20)T the object-group network command has been introduced outside of the ASA family.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And since rix.is holds out a list of icelandic subnets i got the idea to open access to various services only to icelanders :)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The idea isn't new but i hope the scripts i created with the help of my dear friend Jón Rúnar will help someone out there.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What we have is very basic stuff, we have a shell script run by cron on a CentOS box that executes wget to grab the list from RIX, a python script to edit the text file so that an ASA/Cisco IOS can use the list, and then an expect script to update the list on the device.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;bash script&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.internetworkpro.org/pastebin/1066/"&gt;http://www.internetworkpro.org/pastebin/1066/&lt;/a&gt;&lt;a href="http://www.internetworkpro.org/pastebin/1067/"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;here we have two branches depending on your platform:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;edit the subnet list from RIX for ASA input&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;a href="http://www.internetworkpro.org/pastebin/1067/" style="text-decoration: none;"&gt;http://www.internetworkpro.org/pastebin/1067/&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;expect script for ASA&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.internetworkpro.org/pastebin/1071/"&gt;http://www.internetworkpro.org/pastebin/1071/&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;edit the subnet list from RIX for Cisco IOS input&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(85, 26, 139);"&gt;&lt;a href="http://www.internetworkpro.org/pastebin/1069/"&gt;http://www.internetworkpro.org/pastebin/1069/&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;expect script for Cisco IOS&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(85, 26, 139); text-decoration: underline;"&gt;&lt;a href="http://www.internetworkpro.org/pastebin/1070/"&gt;http://www.internetworkpro.org/pastebin/1070/&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I'll explain the scripts and such better in a later edit :)&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4963340397675513437-419487518342358228?l=gunnim.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gunnim.blogspot.com/feeds/419487518342358228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gunnim.blogspot.com/2009/02/blocking-non-icelandic-traffic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4963340397675513437/posts/default/419487518342358228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4963340397675513437/posts/default/419487518342358228'/><link rel='alternate' type='text/html' href='http://gunnim.blogspot.com/2009/02/blocking-non-icelandic-traffic.html' title='Blocking non-icelandic traffic'/><author><name>Gunni M</name><uri>http://www.blogger.com/profile/01904429404624066667</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
