<?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-33511796</id><updated>2011-11-28T11:58:17.734+11:00</updated><category term='linux'/><category term='screen'/><category term='url'/><category term='Gallery2'/><category term='gdd07au'/><category term='encoding'/><category term='Debian'/><category term='security'/><category term='loopback'/><category term='mailto'/><category term='Etch'/><category term='at'/><category term='ssh'/><category term='PostgrsQL'/><category term='Skype'/><category term='firewalls'/><category term='shell'/><category term='pilatesinsightstudio'/><category term='html'/><category term='grox'/><category term='gdd07'/><category term='PHP5'/><category term='iptables'/><category term='X11'/><category term='Apache2'/><title type='text'>Chevrolet '66</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Amos Shapira</name><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>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-33511796.post-4438705468815972646</id><published>2008-06-13T14:21:00.002+10:00</published><updated>2008-06-13T14:22:20.444+10:00</updated><title type='text'>High IQ? Then you can't be a policeman</title><content type='html'>A man is barred from interview to the New London police for having too high IQ.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-4438705468815972646?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://query.nytimes.com/gst/fullpage.html?res=9A06E2DB143DF93AA3575AC0A96F958260' title='High IQ? Then you can&apos;t be a policeman'/><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/4438705468815972646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=4438705468815972646' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/4438705468815972646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/4438705468815972646'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2008/06/high-iq-then-you-cant-be-policeman.html' title='High IQ? Then you can&apos;t be a policeman'/><author><name>Amos Shapira</name><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-33511796.post-2356126406323681170</id><published>2007-10-31T21:12:00.000+11:00</published><updated>2007-10-31T21:15:05.794+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='screen'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='at'/><category scheme='http://www.blogger.com/atom/ns#' term='shell'/><title type='text'>Screen to the rescue</title><content type='html'>I couldn't find a BitTorrrent client which can be executed without a terminal (and therefore from within "at") in time for tonight so attaching "screen -d -m btdownloadcurses ..." solved the problem. This starts the command in a detached screen session so on one hand the command thinks it has a terminal while on the other hand I can still start it from inside "at", which doesn't have a terminal. It also has the added benefit of being able to attach back to that screen session later to see how it goes, which is the main advantage of "screen".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-2356126406323681170?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/2356126406323681170/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=2356126406323681170' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/2356126406323681170'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/2356126406323681170'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2007/10/screen-to-rescue.html' title='Screen to the rescue'/><author><name>Amos Shapira</name><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-33511796.post-8749229663281932594</id><published>2007-10-30T22:52:00.000+11:00</published><updated>2007-11-01T06:41:12.677+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='url'/><category scheme='http://www.blogger.com/atom/ns#' term='encoding'/><category scheme='http://www.blogger.com/atom/ns#' term='grox'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='mailto'/><category scheme='http://www.blogger.com/atom/ns#' term='pilatesinsightstudio'/><title type='text'>Encoding email addresses in HTML pages</title><content type='html'>A while ago I noticed that &lt;a href="http://grox.com.au/"&gt;&lt;span style="text-decoration: underline;"&gt;GROX&lt;/span&gt;&lt;/a&gt; use URL encoding to put their e-mail address&lt;br /&gt;in a "mailto" link. I guess they do this in order to make it more difficult for address harvesters to pick up their e-mail.&lt;br /&gt;&lt;br /&gt;In order to do the same for my wife's web site at &lt;a href="http://pilatesinsightstudio.com/"&gt;http://pilatesinsightstudio.com&lt;/a&gt; I found the following couple of tricks:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The "mailto" link is encoded using: &lt;blockquote&gt;perl -e 'use URI::Escape; print uri_escape("the@email.address", "\0-\377"), "\n";'&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;The title of the link, which I wanted to contain the e-mail address in HTML, was created simply by using the &lt;a href="http://www.codehouse.com/webmaster_tools/html_encoder/"&gt;HTML Encoder from CodeHouse&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-8749229663281932594?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/8749229663281932594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=8749229663281932594' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/8749229663281932594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/8749229663281932594'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2007/10/encoding-emails-in-html-pages.html' title='Encoding email addresses in HTML pages'/><author><name>Amos Shapira</name><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-33511796.post-6531180468124305356</id><published>2007-10-10T20:15:00.000+10:00</published><updated>2007-10-10T20:19:18.625+10:00</updated><title type='text'>Installing local .deb files with dependencies</title><content type='html'>This ("how to install a local .deb file and have all its dependencies automatically pulled from repositories") seems to be an issue which many people ask but nobody gives the current "right answer" which is simply &lt;a href="http://packages.debian.org/etch/gdebi"&gt;gdebi&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-6531180468124305356?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/6531180468124305356/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=6531180468124305356' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/6531180468124305356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/6531180468124305356'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2007/10/installing-local-deb-files-with.html' title='Installing local .deb files with dependencies'/><author><name>Amos Shapira</name><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-33511796.post-7008748032915463248</id><published>2007-05-31T20:28:00.000+10:00</published><updated>2007-05-31T20:44:12.687+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gdd07au'/><category scheme='http://www.blogger.com/atom/ns#' term='gdd07'/><title type='text'>Google Developer Day, Sydney 31 May 2007</title><content type='html'>Just returned from the &lt;a href="http://code.google.com/events/developerday/au-home.html"&gt;Google Developer Day in Sydney&lt;/a&gt;&lt;br /&gt;Learned and refreshed my memory on cool Google staff, especially their API's for integrating extarnal web applications with their.&lt;br /&gt;Some random points, in no particular order:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Contrary to popular perception - Google Earth for Linux does &lt;span style="font-style: italic;"&gt;not&lt;/span&gt; consist on WINE. It's built on QT. Michael Ashbridge, one of the principal developers, tells me how they keep asking TrollTech to fix some of their quirks (e.g. can't copy a selected a text on Mac using the standard keyboard shortcuts). And before anyone tells me that I'm out of date about "Popular Perception" - another speaker from Google, who works with Google Earth every day, was also sure that it's based on WINE so I'm not the only out of touch.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Google Web Toolkit (GWT) AJAX applications can control which stage in the application will enter the browser history and thus be bookmark-able and possible to return to using the browsers "back" button. I wonder how they do this - maybe they just "manually" add the URL to the browser's history?&lt;br /&gt;Anyway, that's one sour point that WebCollage used to go to lengths in order to achieve it. Knowing that the people at WebCollage are pretty damn bright I suspect this is a relativelly recent addition (my information on WebCollage is circa 2000 so maybe it's no longer relevant).&lt;/li&gt;&lt;li&gt;Google Gears looks cool - maybe it'll allow me to provide a version of Soarcast (the gliding weather conditions forecasting program) which can be downloaded to a mobile device, fetch the relevant data off the web and continue presenting the data and calculation results while being offline in the glider port.&lt;/li&gt;&lt;/ol&gt;Lots of other ideas come up when hearing about these tools. Theforemost one is about new ways to implement an old idea - a web site which lists the Australian Gliding clubs on a google map and provides soarcast output for each selected club.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-7008748032915463248?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/7008748032915463248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=7008748032915463248' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/7008748032915463248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/7008748032915463248'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2007/05/google-developer-day-sydney-31-may-2007.html' title='Google Developer Day, Sydney 31 May 2007'/><author><name>Amos Shapira</name><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-33511796.post-405017372198223845</id><published>2007-05-29T10:45:00.000+10:00</published><updated>2007-05-29T11:10:32.454+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Debian'/><category scheme='http://www.blogger.com/atom/ns#' term='X11'/><title type='text'>Smoother X11 fonts</title><content type='html'>Something I found a long time ago and now had to lookup again so it's time to write it down here.&lt;br /&gt;&lt;br /&gt;In order to enable smoother (and nicer, IMO) fonts on X11 you have to have the following in your ~/.fonts.conf:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;?xml version="1.0"?&gt;&lt;br /&gt;&amp;lt;!DOCTYPE fontconfig SYSTEM "fonts.dtd"&gt;&lt;br /&gt;&amp;lt;fontconfig&gt;&lt;br /&gt; &amp;lt;dir&gt;~/.fonts&amp;lt;/dir&gt;&lt;br /&gt; &amp;lt;match target="font"&gt;&lt;br /&gt;  &amp;lt;edit name="autohint" mode="assign"&gt;&lt;br /&gt;   &amp;lt;bool&gt;true&amp;lt;/bool&gt;&lt;br /&gt;  &amp;lt;/edit&gt;&lt;br /&gt; &amp;lt;/match&gt;&lt;br /&gt;&amp;lt;/fontconfig&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;On Debian things are easier - the global settings for the entire system can be enabled by running the following as root:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;# ln -s ../conf.avail/10-autohint.conf /etc/fonts/conf.d&lt;/pre&gt;&lt;/span&gt;And re-startting the X server (not sure a logout/login is enough).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-405017372198223845?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/405017372198223845/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=405017372198223845' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/405017372198223845'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/405017372198223845'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2007/05/smoother-x11-fonts.html' title='Smoother X11 fonts'/><author><name>Amos Shapira</name><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-33511796.post-3855925114215478932</id><published>2007-02-22T16:45:00.000+11:00</published><updated>2007-02-22T17:44:43.994+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PostgrsQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Etch'/><category scheme='http://www.blogger.com/atom/ns#' term='Gallery2'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP5'/><category scheme='http://www.blogger.com/atom/ns#' term='Debian'/><category scheme='http://www.blogger.com/atom/ns#' term='Apache2'/><title type='text'>Setting up Gallery2+PostgresQL+PHP5 on Debian Etch</title><content type='html'>The Gallery2 package for Debian Etch seems to be very well done, except one thing - it's geared towards MySQL usage (the Gallery makers recommend MySQL because they say that they use some special MySQL constructs which have to be emulated on other databases).&lt;br /&gt;My view on this is:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;I prefer PostgresQL - it's a more mature database.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I prefer Apache2&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I prefer PHP5 - I hate this language and think it has tendency to push poor programmers to shoot themselves (and their users) in their feet but if I have to install it on my machine then I'd rather use the latest and greatest.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I prefer mod-php5 as opposed to the other ways to integrate Apache2 with PHP.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;In addition, the Debian packages state their dependencies in a way that seems to encourage Aptitude to choose Apache (1), MySQL and PHP4.&lt;br /&gt;&lt;p/&gt;&lt;br /&gt;So first thing first: After picking gallery2 for installation in Aptitude, go through all the packages it depends on and remove the ones you don't want and which have other alternatives. Get rid of the PHP4 and MySQL dependencies - Aptitude makes it pretty easy by simply making sure that you choose other packages to satisfy the dependencies  and remove the rest. Just follow the suggestions made by Aptitude when you ask to remove a package with dependencies on it, and make sure that Aptitude doesn't signal "Broken Packages" before going ahead to execute the changes.&lt;br /&gt;&lt;p/&gt;&lt;br /&gt;Setup a separate user for gallery:&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$ sudo adduser --system --group gallery&lt;/span&gt;&lt;br /&gt;&lt;p/&gt;&lt;br /&gt;Does the trick - add a system user (with a shell of /bin/false), create a home directory for it and a group especially for it.&lt;br /&gt;&lt;p/&gt;&lt;br /&gt;The following should be pretty self-explanatory but the summary is: Create a new role ("user"), create a database, set a password, allow role to be logged in:&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$ sudo -u postgres psql&lt;br /&gt;postgres=# create role gallery;&lt;br /&gt;postgres=# create database gallery owner gallery;&lt;br /&gt;postgres=# alter role gallery encrypted password 'password';&lt;br /&gt;postgres=# alter role gallery login;&lt;br /&gt;postgres=# \q&lt;/span&gt;&lt;br /&gt;Allow logging in to role "gallery" from another user without having to run psql as the UNIX user "gallery" by adding the following lines to the end of /etc/postgresql/8.1/main/pg_hba.conf:&lt;br /&gt;&lt;p/&gt;&lt;span style="font-family: courier new;"&gt;local gallery gallery md5&lt;/span&gt;&lt;br /&gt;&lt;p/&gt;&lt;br /&gt;And I also had to enable access to Gallery2's index.php by adding "Indexes" to the Options line in /etc/apache2/conf.d/gallery2 (link to /etc/gallery2/apache.conf&lt;br /&gt;&lt;p/&gt;&lt;br /&gt;After that I could access my web server's "/photos/" and start the automatic configuration.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-3855925114215478932?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://codex.gallery2.org/Main_Page' title='Setting up Gallery2+PostgresQL+PHP5 on Debian Etch'/><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/3855925114215478932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=3855925114215478932' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/3855925114215478932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/3855925114215478932'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2007/02/setting-up-gallery2postgresqlphp5-on.html' title='Setting up Gallery2+PostgresQL+PHP5 on Debian Etch'/><author><name>Amos Shapira</name><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-33511796.post-3568607491667815941</id><published>2007-02-15T11:22:00.000+11:00</published><updated>2007-02-15T11:51:54.147+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firewalls'/><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='Skype'/><category scheme='http://www.blogger.com/atom/ns#' term='iptables'/><title type='text'>How to block Skype traffic with one iptables rule</title><content type='html'>There is an interesting lecture (&lt;a href="http://www.blackhat.com/presentations/bh-europe-06/bh-eu-06-biondi/bh-eu-06-biondi-up.pdf"&gt;PDF&lt;/a&gt;) by Philippe Biondi and Fabrice Desclaux  about how and what they learned about the Skype client code and protocol. On page 75 they give the following secret incantation for blocking Skype traffic:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;iptables -I FORWARD −p udp −m length −−length 39 −m u32 &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;−−u32 ’27&amp;amp;0x8f=7’ −−u32 ’31=0x527c4833’ −j DROP&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-3568607491667815941?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/3568607491667815941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=3568607491667815941' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/3568607491667815941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/3568607491667815941'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2007/02/how-to-block-skype-traffic-with-one.html' title='How to block Skype traffic with one iptables rule'/><author><name>Amos Shapira</name><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>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-33511796.post-7382093976409434274</id><published>2007-02-09T12:57:00.000+11:00</published><updated>2007-02-06T13:51:09.921+11:00</updated><title type='text'>xdns - archeological diggings</title><content type='html'>Finally I re-found my own DNS Library source still almost at the &lt;a href="ftp://ftp.cs.huji.ac.il/pub/network/dns/xdns.tar.gz"&gt;same place&lt;/a&gt; where I left it almost 15 years ago.&lt;br /&gt;&lt;br /&gt;Granted - the "xdns" program around it is pretty useless today, and the dns packet creation and parsing library is a classic candidate for C++ -style Object-based interface, but the basics are still there and might be useful for others who still have to deal with raw DNS packets...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-7382093976409434274?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/7382093976409434274/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=7382093976409434274' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/7382093976409434274'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/7382093976409434274'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2007/02/xdns-archeological-diggings.html' title='xdns - archeological diggings'/><author><name>Amos Shapira</name><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-33511796.post-1246428252610940028</id><published>2007-02-01T11:24:00.000+11:00</published><updated>2007-02-16T15:56:29.243+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='ssh'/><category scheme='http://www.blogger.com/atom/ns#' term='loopback'/><title type='text'>SSH breaks when the loopback device isn't configured</title><content type='html'>Helping others troubleshooting is great fun and very rewarding  - you get to learn some new things yourself.&lt;br /&gt;&lt;br /&gt;In this case, this chap had a trouble getting X11 forwarded over an SSH tunnel. Everything looked fine, the same setup on another machine worked just as it should, all the flags (X11Forwarding) were set correctly but still the $DISPLAY envariable wasn't set on the remote side.&lt;br /&gt;&lt;br /&gt;The bottom line - the loopback device ("lo") wasn't configured. This can be checked with a simple "ifconfig".&lt;br /&gt;&lt;br /&gt;The break-through in the investigation came when he executed sshd in debug mode and received the following errors:&lt;br /&gt;&lt;pre&gt;debug2: bind port 6999: Cannot assign requested address&lt;br /&gt;...&lt;br /&gt;Failed to allocate internet-domain X11 display socket.&lt;br /&gt;&lt;/pre&gt;Some googling revealed the following post, which actually gave the answer (so at least  some of the credit should go to Jim Prewett, who bothered to document his findings four years ago): &lt;a href="http://marc.theaimsgroup.com/?l=openssh-unix-dev&amp;m=104336969724537"&gt;http://marc.theaimsgroup.com/?l=openssh-unix-dev&amp;amp;m=104336969724537&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;WARNING: You have to run sshd in debug mode on an alternate port because sshd debug mode will only serve one connection then exit, so you have to keep your existing non-debug sshd running or else you'll lock yourself out.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-1246428252610940028?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://lists.slug.org.au/archives/slug/2007/01/msg00544.html' title='SSH breaks when the loopback device isn&apos;t configured'/><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/1246428252610940028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=1246428252610940028' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/1246428252610940028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/1246428252610940028'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2007/02/ssh-breaks-when-loopback-isnt-there.html' title='SSH breaks when the loopback device isn&apos;t configured'/><author><name>Amos Shapira</name><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-33511796.post-116054615904526221</id><published>2006-10-11T15:50:00.000+10:00</published><updated>2006-10-11T15:57:10.546+10:00</updated><title type='text'>Parallel xargs and faster ssh connection initiation</title><content type='html'>You learn something new every day, even with old friends such as ssh and xargs.&lt;br /&gt;&lt;br /&gt;SSH: It turns out that it's possible to create a live "Master" connection to a specific remote host which then can be used by other ssh command executions to quickly open sub-channels to that host without going through the authentication process every time and without compromising on security.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ ssh -fMN -o ControlPath=~/.ssh-control-sock remote-host&lt;br /&gt;$ ssh -o ControlPath=~/.ssh-control-sock remote-host date&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;more about this in ssh(1) and ssh_config(5)&lt;br /&gt;&lt;br /&gt;XARGS: In response to some Digg pointer to xjobs, which seems to be similar to xargs only it can run multiple jobs in parallel, someone pointed out to xargs' own -P (--max-procs) argument which does exactly the same. Just have to remember to limit the number of file names passed to each job using -n (--max-args), otherwise all the file names will be passed to a single job.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-116054615904526221?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/116054615904526221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=116054615904526221' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/116054615904526221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/116054615904526221'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2006/10/parallel-xargs-and-faster-ssh.html' title='Parallel xargs and faster ssh connection initiation'/><author><name>Amos Shapira</name><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-33511796.post-115892203461528248</id><published>2006-09-22T20:08:00.000+10:00</published><updated>2006-09-29T22:19:51.146+10:00</updated><title type='text'>The final IPTables setup and some initial results</title><content type='html'>Hi and welcome back. I've just realized that I haven't published the final solution for data gathering. So in this post I'll:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Describe the IPTables setup&lt;/li&gt;&lt;li&gt;Show the initial script I wrote to read the results&lt;/li&gt;&lt;li&gt;Show some preliminary raw data&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-weight: bold;"&gt;IPTables Setup&lt;/span&gt;&lt;br /&gt;I've changed the setup described in the first post about the subject to also add the "foreign" side of each identified Skype connection to the "recent" list (using the "recent" module). That way when an ICMP packet arrives from a host in that list I assume that it's related to Skype (I guess there are very slim chances to have Skype traffic with a server such as web hosts).&lt;br /&gt;&lt;br /&gt;Here is the updated setup:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;&lt;br /&gt;# match all outgoing packets from gid skype, mark their connection&lt;br /&gt;# and add their destination to the "recent list" so we can count ICMP packets to/from them&lt;br /&gt;iptables -A OUTPUT -m owner --gid-owner skype --out-interface eth0   --protocol tcp -m recent --rdest --set --name Skype -j CONNMARK --set-mark 1&lt;br /&gt;iptables -A OUTPUT -m owner --gid-owner skype --out-interface eth0   --protocol udp -m recent --rdest --set --name Skype -j CONNMARK --set-mark 2&lt;br /&gt;&lt;br /&gt;# count ICMP packets going to hosts which appear in our "recent" list&lt;br /&gt;iptables -A OUTPUT --out-interface eth0 --protocol icmp -m recent --rdest   --name Skype --update -j ACCEPT -m comment --comment skype-out-icmp&lt;br /&gt;&lt;br /&gt;# all packets which match the connection should go through the skype rule&lt;br /&gt;iptables -A OUTPUT -m connmark --mark 1 -m comment --comment skype-out-tcp&lt;br /&gt;iptables -A OUTPUT -m connmark --mark 2 -m comment --comment skype-out-udp&lt;br /&gt;&lt;br /&gt;# match all packets on Skype's public TCP port and mark their connection&lt;br /&gt;iptables -A INPUT -p tcp -m tcp --dport 21212 --in-interface eth0 -j CONNMARK --set-mark 1&lt;br /&gt;iptables -A INPUT -p udp -m udp --dport 21212 --in-interface eth0 -j CONNMARK --set-mark 2&lt;br /&gt;# count ICMP packets coming from hosts which appear in our "recent" list&lt;br /&gt;iptables -A INPUT -p icmp --in-interface eth0 -m recent --name Skype   --update -j ACCEPT -m comment --comment skype-in-icmp&lt;br /&gt;&lt;br /&gt;# all packets which match the connection&lt;br /&gt;iptables -A INPUT -m connmark --mark 1 -m comment --comment skype-in-tcp&lt;br /&gt;iptables -A INPUT -m connmark --mark 2 -m comment --comment skype-in-udp&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;The counter reading script was modified to add "icmp" to the list of protocols it looks for and to total bytes/packets over the various planes: direction (total in vs. total out) and protocol (tcp vs. udp vs. icmp)&lt;br /&gt;&lt;br /&gt;Here is what the counters look like after about 25 days of data gathering:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;&lt;br /&gt;$ sudo ./getcounts.pl&lt;br /&gt;tcp_out_bytes   35838386&lt;br /&gt;icmp_out_bytes  155016&lt;br /&gt;tcp_in_pkts     441671&lt;br /&gt;icmp_out_pkts   1023&lt;br /&gt;icmp_in_pkts    4526&lt;br /&gt;udp_out_bytes   242046393&lt;br /&gt;tcp_out_pkts    540629&lt;br /&gt;icmp_in_bytes   505522&lt;br /&gt;udp_out_pkts    1799468&lt;br /&gt;udp_in_pkts     1607313&lt;br /&gt;udp_in_bytes    204286584&lt;br /&gt;tcp_in_bytes    42500198&lt;br /&gt;====== totals =====&lt;br /&gt;tcp_pkts        982300&lt;br /&gt;tcp_bytes       78338584&lt;br /&gt;icmp_pkts       5549&lt;br /&gt;out_pkts        2341120&lt;br /&gt;icmp_bytes      660538&lt;br /&gt;udp_bytes       446332977&lt;br /&gt;in_bytes        247292304&lt;br /&gt;udp_pkts        3406781&lt;br /&gt;out_bytes       278039795&lt;br /&gt;in_pkts         2053510&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;I'm still looking for time to add writing of these numbers into an RRD file so it'll be possible to graph them across different periods, but for now my simple conslusion is about the "in_bytes" numbers (and to a lesser degree, the "out_bytes"): they are 235.8 incoming mega bytes and 265.1 outgoing mega bytes.&lt;br /&gt;&lt;br /&gt;Over a period of 25 days this puts it at around 9.4 incoming mega bytes per day and 10.6 outgoing megabytes per day. Over a month (let's say it's 30 days) it's 283.0 mega bytes per month of incoming traffic and 318.2 mega bytes of outgoing traffic. This includes my own Skype conversations (admittedly, not much this month).&lt;br /&gt;&lt;br /&gt;Whether this proves Cringley's point or not? I'm not sure. I didn't believe that there is &lt;span style="font-style:italic;"&gt;that&lt;/span&gt; much traffic involved until I startted this experiment, but I'm still not completly convinced it's "too much to handle".&lt;br /&gt;&lt;br /&gt;In my personal context it's still less than 2% (1.38%, to be precise) of my download quota of 20Gb per month.&lt;br /&gt;&lt;br /&gt;So for now I'm not going to give up on the advantages of a smoother connection (which is the reason I configured my desktop as a "Super-node" in the first place).&lt;br /&gt;&lt;br /&gt;I'd be glad to learn from you what you think about the experiment (have I missed some packets?) and the result - do you agree with my conclusion so far or not?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-115892203461528248?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/115892203461528248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=115892203461528248' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/115892203461528248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/115892203461528248'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2006/09/final-iptables-setup-and-some-initial.html' title='The final IPTables setup and some initial results'/><author><name>Amos Shapira</name><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>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-33511796.post-115763032912173134</id><published>2006-09-07T21:31:00.000+10:00</published><updated>2006-09-07T22:00:27.233+10:00</updated><title type='text'>Work journal - u32 isn't going to make it(?)</title><content type='html'>I was planning to use the IPTables U32 module to look at the "original packet" which is included in the ICMP packets destined to Skype-related connection attempts but this might not cut it because there are other ICMP messages involved, not just the "port unreachable" I saw at first.&lt;br /&gt;&lt;br /&gt;Instead, now I plan to use the "recent" module.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Note: try running "&lt;span style="font-family:courier new;"&gt;iptables -m recent -h&lt;/span&gt;" to list options not mentioned in the manual. Apparently it's a good thing to do with any IPTables module&lt;/span&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The "&lt;a href="http://snowman.net/projects/ipt_recent/"&gt;recent&lt;/a&gt;" module is designed with "keep the bad guys out" situation in mind (by adding attacker's source address to a tempoary list) but with the "secret" --rdest option, which allows me to add destination addresses of outgoing packets, it might be possible to add the IP of any host with which Skype have just attempted to converse to a temporary cache which will allow this host to send back errors and which will automatically expire in a preset time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-115763032912173134?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/115763032912173134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=115763032912173134' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/115763032912173134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/115763032912173134'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2006/09/work-journal-u32-isnt-going-to-make-it.html' title='Work journal - u32 isn&apos;t going to make it(?)'/><author><name>Amos Shapira</name><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-33511796.post-115760308792034497</id><published>2006-09-07T14:13:00.000+10:00</published><updated>2006-09-07T18:28:46.776+10:00</updated><title type='text'>Counting Skype traffic - Part 1 - Gathering the data</title><content type='html'>In his weekly column "&lt;a href="http://www.pbs.org/cringely/pulpit"&gt;I, Cringly&lt;/a&gt;", Robext X. Cringly made the statement that Skype's Supernodes (nodes which offer to mediate traffic for other nodes which can't talk directly with each other because both of them are behind NAT) &lt;a href="http://www.pbs.org/cringely/pulpit/pulpit20060713.html"&gt;suffer from a very high load of traffic&lt;/a&gt; which isn't actually used for the Supernode's owner benefit but for other users.&lt;br /&gt;&lt;br /&gt;In &lt;a href="http://www.pbs.org/cringely/pulpit/pulpit20060720.html"&gt;a later entry in his column&lt;/a&gt;, in response to comments he received from readers, he goes on to insist that his statement is true and gives Standford University banishment of Skype for that reason as a proof.&lt;br /&gt;&lt;br /&gt;This is an interesting topic for me since I set up my home box as a Supernode because this cuts down dramatically the number of hops skype uses to connect me with people abroad (from 4 hops to 0). Since I buy quota for my ADSL line from my ISP I was concerned how much Skype uses out of this but so far, over a year since I started doing this, I haven't noticed that I use any significant part of my quota, but I couldn't tell exactly which part of my traffic is Skype-related.&lt;br /&gt;&lt;br /&gt;That is, until Cringley's column made that itch to scratch too much and I got off my butt to find out.&lt;br /&gt;&lt;br /&gt;After a quick check around with colleagues and a quick question on Linux-Il I learned that Linux's IPTables have an "owner" module which does basically just that - filter packets based on the attributes of the process which generates them, be it by command name, uid, gid or similar stuff.&lt;br /&gt;&lt;br /&gt;There are some warnings in the IPTables documents that uid and command-name checks work only on non-SMP kernels. The warnings don't mention problems with GID checks. That shouldn't be a big problem in my particular case since I have an old Athlon AMD x32 CPU but for sake of completeness I created a group "skype", made the Skype binary belong to that group and turned on its set-group-id bit, so any process executing this binary actually has GID of "skype".&lt;br /&gt;&lt;br /&gt;It also turns out that Skype apparently sends lots of packets to itself over the loopback interface, so I had to make sure I don't count these since they shouldn't affect my Internet traffic.&lt;br /&gt;&lt;br /&gt;But that would work only for outgoing traffic - what about incoming traffic on these connections?&lt;br /&gt;&lt;br /&gt;Simple! When Skype sends an outgoing packet the entire connection can be marked as "belonging to Skype" so even incoming packets on the same connection will be counted. So I got this part covered.&lt;br /&gt;&lt;br /&gt;For sake of curiosity, I mark TCP and UDP connections with different marks so I can distinguish them in the statistics.&lt;br /&gt;&lt;br /&gt;Here are the iptable rules related to this:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;&lt;br /&gt;# iptables -A OUTPUT -m owner --gid-owner skype --out-interface eth0 --protocol tcp -j CONNMARK --set-mark 1&lt;br /&gt;# iptables -A OUTPUT -m owner --gid-owner skype --out-interface eth0 --protocol udp -j CONNMARK --set-mark 2&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;The first line means: "Append a rule to the OUTPUT chain which will mark TCP connections containing packets from GID 'skype' with connection mark '1'". The second line does the same for UDP only it marks the connections with connection mark '2'.&lt;br /&gt;&lt;br /&gt;This should solve the problem for connections initiated by my Skype client.&lt;br /&gt;&lt;br /&gt;Now there is another kind of connections - those initiated by other clients.&lt;br /&gt;&lt;br /&gt;Now what does it actually mean that my Skype client is configured as a Supernode? It means that it listens on certain UDP and TCP ports for incoming connections (something that non-Supernodes don't have to do since all their traffic is done over connections which they initiate). Any host on the Internet can access these ports through the firewall directly to my Skype client. (In my case I actually had to also configure my ADSL modem/router/NAT to allow incoming connections to this port but that's a separate issue which shouldn't affect the subject of this post).&lt;br /&gt;&lt;br /&gt;The practical meaning of this is that incoming packets which initiate a new connection to Skype don't get counted as belonging to it because the IPTable "owner" module only recognizes &lt;span style="font-style: italic;"&gt;outgoing&lt;/span&gt; packets. The connections will still eventually get counted because Skype will (hopefully) reply to these connections - but the first incoming packet of that connection won't be counted because it will be gone by the time IPTables realizes that this is a "Skype" traffic. The way to identify incoming new connections is simply to mark all new connections to the published TCP and UDP ports as belonging to Skype too:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;# iptables -A INPUT -p tcp -m tcp --dport 21212 --in-interface eth0 -j CONNMARK --set-mark 1&lt;br /&gt;# iptables -A INPUT -p udp -m udp --dport 21212 --in-interface eth0 -j CONNMARK --set-mark 2&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;The first line says "Append a line to the INPUT chain which marks all incoming TCP connections to Skype's designated TCP port (21212) which come from the Ethernet card with connection mark '1'". The second line does the same for UDP packets and using connection mark of "2".&lt;br /&gt;&lt;br /&gt;All these rule do is to attach connection marks to packets. In order to actually &lt;span style="font-style: italic;"&gt;count&lt;/span&gt; the packets I setup four separate rules with comments, and later grab the data off these rules:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;&lt;br /&gt;# iptables -A OUTPUT -m connmark --mark 1 -m comment --comment skype-out-tcp&lt;br /&gt;# iptables -A OUTPUT -m connmark --mark 2 -m comment --comment skype-out-udp&lt;br /&gt;# iptables -A INPUT -m connmark --mark 1 -m comment --comment skype-in-tcp&lt;br /&gt;# iptables -A INPUT -m connmark --mark 2 -m comment --comment skype-in-udp&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;All these rule do is to match the relevant packets - they don't have to do anything about the packet - IPTables already keeps counts of all matching packets and number of bytes for each rule, and the attached comments make it easy to identify the relevant rules:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;use IPTables::IPv4;&lt;br /&gt;sub get_counts {&lt;br /&gt;  my %counts = ();&lt;br /&gt;  my $table = IPTables::IPv4::init('filter');&lt;br /&gt;  unless ($table) {&lt;br /&gt;    warn "failed to initialize: $!\n"; return undef;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  my @rules = ($table-&gt;list_rules("INPUT"), $table-&gt;list_rules("OUTPUT"));&lt;br /&gt;  foreach my $rule (@rules) {&lt;br /&gt;    exists $rule-&gt;{'comment-match-raw'} or next;&lt;br /&gt;    $rule-&gt;{'comment-match-raw'} =~ /^skype-(in|out)-(tcp|udp)\0+$/ or next;&lt;br /&gt;    $counts{"$2_$1_bytes"} = $rule-&gt;{bcnt};&lt;br /&gt;    $counts{"$2_$1_pkts"} = $rule-&gt;{pcnt};&lt;br /&gt;  }&lt;br /&gt;  return %counts;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;my %counts = get_counts;&lt;br /&gt;while (my ($key, $value) = each %counts) {&lt;br /&gt;  print "$key =&gt; $value\n";&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;The "&lt;span style="font-family:courier new;"&gt;$2_$1_bytes&lt;/span&gt;" and "&lt;span style="font-family:courier new;"&gt;$2_$1_pkts&lt;/span&gt;" strings are preparations for DataSource (DS) names to be used in &lt;a href="http://oss.oetiker.ch/rrdtool/"&gt;RRD files&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Still to come:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Counting ICMP ECHO requests ("ping") coming from other Skype users (and letting them through but still keeping requests from non-Skype users out) using IPTAbles U32 matching module and possibly "recent" module.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Saving the results in RRD files.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Graphing the results from the RRD files.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Drawing conclusions?&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-115760308792034497?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/115760308792034497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=115760308792034497' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/115760308792034497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/115760308792034497'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2006/09/counting-skype-traffic-part-1.html' title='Counting Skype traffic - Part 1 - Gathering the data'/><author><name>Amos Shapira</name><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-33511796.post-115681728424180381</id><published>2006-08-29T12:05:00.000+10:00</published><updated>2006-09-07T14:06:46.530+10:00</updated><title type='text'>Listing the body of a Bash function</title><content type='html'>Everybody who knows something knows that typing "set" in bash(1) will list the values of all shell variables, aliases and functions.&lt;br /&gt;&lt;br /&gt;But I wanted to find the definition of a function without having to "set | less" and manually looking for it in the output.&lt;br /&gt;&lt;br /&gt;Turns out that typing "type &lt;function&gt;" will give me what I wanted. Only "drawback" is that it also gives a line at the top saying "&lt;function&gt; is a function", which is sort of good because it should allow some automatic way to know what to expect next.&lt;/function&gt;&lt;/function&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-115681728424180381?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/115681728424180381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=115681728424180381' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/115681728424180381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/115681728424180381'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2006/08/listing-body-of-bash-function.html' title='Listing the body of a Bash function'/><author><name>Amos Shapira</name><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-33511796.post-115760215911529243</id><published>2006-07-05T05:13:00.000+10:00</published><updated>2006-09-07T15:48:30.856+10:00</updated><title type='text'>Accessing private web servers through SSH</title><content type='html'>I've always knew that it's possible to channel any TCP traffic through &lt;a href="http://www.openssh.org/"&gt;ssh&lt;/a&gt; but never got around to actually use it (beyond running the SSH client with "&lt;span style="font-family: courier new;"&gt;-X&lt;/span&gt;" to forward X11 traffic) but today I got around to actually test this.&lt;br /&gt;&lt;br /&gt;The problem: access devices like my &lt;a href="http://forums.whirlpool.net.au/index.cfm?a=h_view&amp;amp;model_id=166"&gt;Dlink DSL504G ADSL modem&lt;/a&gt; web interface or &lt;a href="http://www.sipura.com/products/spa3000.htm"&gt;Sipura SPA-3000 ATA&lt;/a&gt;'s web interface from my desktop at work.&lt;br /&gt;&lt;br /&gt;The solution: actually there are a few of them, I'll list them by the order I tried them:&lt;br /&gt;&lt;br /&gt;1. "&lt;span style="font-family:courier new;"&gt;ssh -L 30000:192.168.1.3:80 my-home-machine&lt;/span&gt;" - This tells my SSH client at work that if I connect to port 3000 on my desktop at work it should connect host "192.168.1.3" port "80" from my home machine. This is the private-network address of my ADSL modem. Now I just typed "&lt;span style="font-family:courier new;"&gt;localhost:30000&lt;/span&gt;" in Firefox on my work desktop and got the web interface of my ADSL modem at home. I could add another port (let's say port 30001) to forward connections to my ATA device.&lt;br /&gt;&lt;br /&gt;2. Just "&lt;span style="font-family:courier new;"&gt;ssh my-home-machine&lt;/span&gt;" then type "&lt;span style="font-family:courier new;"&gt;~C&lt;/span&gt;" this brings up a command line interface which allows me to then type "&lt;span style="font-family:courier new;"&gt;-L 30000:192.168.1.3:80&lt;/span&gt;" - the effect is just the same as specifying this command line argument on the ssh command line but the advantage is that I don't have to open a new session if I already have one.&lt;br /&gt;&lt;br /&gt;3. Last but not least (but I ended up not using it): add a line to the configuration in &lt;span style="font-family:courier new;"&gt;~/.ssh/config&lt;/span&gt; saying "&lt;span style="font-family:courier new;"&gt;LocalForward 30000 10.1.1.5:80&lt;/span&gt;".&lt;br /&gt;&lt;br /&gt;Right now I plan to use option 2 - that way my private home devices are not open to anyone on my workplace network whenever I ssh home but on the other hand I don't have to open a new session whenever I want to access my home network devices.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33511796-115760215911529243?l=praia-vermelha.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://praia-vermelha.blogspot.com/feeds/115760215911529243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=33511796&amp;postID=115760215911529243' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/115760215911529243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/33511796/posts/default/115760215911529243'/><link rel='alternate' type='text/html' href='http://praia-vermelha.blogspot.com/2006/07/accessing-private-web-servers-through.html' title='Accessing private web servers through SSH'/><author><name>Amos Shapira</name><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>
