<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>
<channel>
	<title>G-Loaded Journal &#187; Networking</title>
	<atom:link href="http://www.g-loaded.eu/tag/networking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.g-loaded.eu</link>
	<description>An open-source software and technology related journal</description>
	<lastBuildDate>Mon, 05 Dec 2011 19:55:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
		<item>
		<title>How secure is the TOR network for everyday internet browsing?</title>
		<link>http://www.g-loaded.eu/2011/04/02/how-secure-is-the-tor-network-for-everyday-internet-browsing/</link>
		<comments>http://www.g-loaded.eu/2011/04/02/how-secure-is-the-tor-network-for-everyday-internet-browsing/#comments</comments>
		<pubDate>Sat, 02 Apr 2011 06:47:02 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[TOR]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=2203</guid>
		<description><![CDATA[I recently read that the Free Software Foundation has given the Award for Projects of Social Benefit to the TOR Project. Congratulations! There are indeed some cases that the TOR network can be extremely useful to the societies. On the other hand, the fact that an organization like the FSF gives this award to the [...]]]></description>
			<content:encoded><![CDATA[<p>I recently read that the Free Software Foundation has given the <em>Award for Projects of Social Benefit</em> to the <a href="https://www.torproject.org/">TOR Project</a>. Congratulations! There are indeed some cases that the TOR network can be extremely useful to the societies. On the other hand, the fact that an organization like the <abbr title="Free Software Foundation">FSF</abbr> gives this award to the TOR project combined with statements like &#8220;<em>People like you and your family use Tor to protect themselves, their children, and their dignity while using the Internet</em>&#8220;, that can be found throughout the TOR project website, may lead the typical internet user into thinking that the TOR network, apart from providing anonymity, is also a secure way of communication, which is far from the truth. I don&#8217;t claim to be a network security expert or an authority on the TOR network, but I don&#8217;t think any expertise is required in order to state the obvious.<br />
<span id="more-2203"></span><br />
At this point, it is useful to roughly describe how TOR works. The TOR network consists of TOR clients, relays and exit nodes. A client connects to the network which initiates the creation of a tunnel that starts at the user&#8217;s location and ends, after following a random route through the relays, to a random exit node. The user configures other software like web browsers or instant messengers to connect to the remote service through this tunnel. Once the request exits the tunnel at the exit-node, it goes through the network of the ISP that provides internet access to the TOR exit-node and it finally reaches the remote service. The response from the remote service follows the inverse route to get back to the user&#8217;s software. This way, the user&#8217;s ISP has absolutely no idea what services the user communicates with, since all user traffic goes through the TOR network and the network of a 3rd party ISP.</p>
<p>So, TOR can provide anonymity as far as the user&#8217;s ISP is concerned, but is it a secure way to communicate with remote services? <strong>If no extra encryption is used</strong>, then it is quite obvious that using remote services through the TOR network is <strong>totally insecure</strong>. Here is why.</p>
<p>The <strong>TOR exit-node</strong> is a key point in the communication between the user and the remote service. This is where the user&#8217;s data exits the TOR tunnel and continues its way to the remote service through the 3rd party ISP&#8217;s network. It is also the place where data from the remote service leaves the 3rd party ISP&#8217;s network and enters the TOR tunnel in order to reach the end user. If no encryption is used, it is possible for the exit-node operator to <strong>sniff this network traffic</strong>. This means that it is technically possible for an evil exit-node operator to:</p>
<ul>
<li>know which web pages the user visits</li>
<li>read the messages the user exchanges through unencrypted IM networks</li>
<li>read the emails the user sends</li>
<li>if the user authenticates to any services without encryption, the evil exit-node operator could for example find out his mailbox or FTP account password or the passwords the user uses for authentication to web sites</li>
<li>even if the authentication to a web service has taken place through an encrypted SSL tunnel, if the rest of the communication with this specific web service is not encrypted, the evil operator could grab a copy of the user&#8217;s  session cookie for this service and access it pretending to be him</li>
</ul>
<p>These are some of the nasty things that can happen <strong>when you access remote services through a proxy server which you do not control</strong>.</p>
<p>Is there any guarantee that exit node operators do not sniff network traffic?</p>
<p>Even if the exit-node operators are cool, who can guarantee that the network traffic is not monitored within the <strong>3rd party ISP</strong>&#8216;s network? If the user accesses personalized services without encryption, then, even if the user&#8217;s real IP and thus his real name is not known, various pieces of collected data can be combined together and possibly reveal his real identity. This process is widely known as <em><a href="http://epic.org/privacy/reidentification/">re-identification</a></em>.</p>
<p>Is there any guarantee that the ISP providing internet access to a TOR exit node does not collect and sell information to &#8220;marketers and identity thieves&#8221;?</p>
<p><strong>I consider the TOR project quite important</strong>. But, since typical internet users are urged to use the TOR network in order to browse the internet, <strong>the involved risks have to be explained in detail</strong>.</p>
<p>On the other hand, I&#8217;d like to urge internet users to spend some time to familiarize themselves with the <strong>basics</strong> of the HTTP protocol, the <strong>concepts</strong> of HTTP authentication and cookie based authentication and the importance of encrypted HTTP connections through <strong>SSL</strong> or <strong>TLS</strong> tunnels. Since the internet has become part of your lives, regardless of your profession, you need to be educated about these things, so as to be able to realize when your communication with the various internet services is vulnerable. You don&#8217;t have to be gurus, but rather get an idea of what is going on.</p>
<p>So far, it is quite clear that the only way to stay on the safe side while using anonymizing proxies on which you usually do not have full control, like TOR, is to connect to any remote services <strong>using encrypted connections only</strong>, usually through SSL or TLS tunnels. Personally, I never use anonymizing networks or third party proxies. This is because I never really had the need to hide my real location. Furthermore, I find it pointless as I don&#8217;t believe that such a thing as anonymity is really feasible. If I had to use TOR, I would try to find a way to connect to the remote service over an encrypted connection. In general, whenever I need a secure SOCKS proxy, for example when I have to use a public network to access personalized internet services, which do not offer full SSL access, I use OpenSSH client&#8217;s <strong>-D switch</strong> while logging in to a SSH server which I own and fully control and thus I have all the security I need.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2011/04/02/how-secure-is-the-tor-network-for-everyday-internet-browsing/">How secure is the TOR network for everyday internet browsing?</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2006/11/24/auto-closing-ssh-tunnels/" rel="bookmark">Auto-closing SSH tunnels</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/configure-vnc-server-in-fedora/" rel="bookmark">Set up the VNC Server in Fedora</a></li>
<li><a href="http://www.g-loaded.eu/2005/10/20/ssh-tunnels-headaches/" rel="bookmark">SSH Tunnels Headaches</a></li>
<li><a href="http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/" rel="bookmark">Netcat &#8211; a couple of useful examples</a></li>
<li><a href="http://www.g-loaded.eu/2008/05/16/using-ssh-for-networking/" rel="bookmark">Using SSH for networking</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2011/04/02/how-secure-is-the-tor-network-for-everyday-internet-browsing/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>DD-WRT support for Wireless N Routers</title>
		<link>http://www.g-loaded.eu/2011/03/28/dd-wrt-support-for-wireless-n-routers/</link>
		<comments>http://www.g-loaded.eu/2011/03/28/dd-wrt-support-for-wireless-n-routers/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 06:16:39 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[DD-WRT]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Router]]></category>
		<category><![CDATA[Wireless]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=2194</guid>
		<description><![CDATA[It&#8217;s been a long time since I last checked the market for WLAN routers. Although I don&#8217;t intend buying one right now, I think staying up to date with the latest advancements in the technology used in these devices is a good idea, because I might need to buy one in the near future. And [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a long time since I last checked the market for WLAN routers. Although I don&#8217;t intend buying one right now, I think staying up to date with the latest advancements in the technology used in these devices is a good idea, because I might need to buy one in the near future. And this time I want to make the right choice, which practically means I want to choose a <em>wireless N router</em> that is <strong>fully supported</strong> by the open source router firmware <a href="http://www.dd-wrt.com">DD-WRT</a>. For those not familiar with DD-WRT:<br />
<span id="more-2194"></span></p>
<blockquote><p>DD-WRT is a Linux based alternative Open Source firmware suitable for a great variety of WLAN routers and embedded systems. The main emphasis lies on providing the easiest possible handling while at the same time supporting a great number of functionalities within the framework of the respective hardware platform used.</p></blockquote>
<p>You can check whether a device is supported by DD-WRT or not by checking the device&#8217;s model name in the <a href="http://www.dd-wrt.com/site/support/router-database">database of supported routers</a>. If you are like me and prefer to read an overview of the wireless N devices instead of querying a database, there is a <a href="http://www.dd-wrt.com/wiki/index.php/Supported_Devices_802.11n">page</a> in the project&#8217;s wiki that lists all these devices.</p>
<p>After checking the technical specifications of several routers on their manufacturer web sites, it is quite clear that at this moment there are not many wireless N routers &#038; ADSL2+ modem combos that are fully supported by DD-WRT. In my case that won&#8217;t be a big problem, but I&#8217;d really like the device to have a <em>DSL port</em> so as to keep the number of devices around the house at a minimum. But anyway, this is not a big deal.</p>
<p>Some other things I&#8217;d consider a plus for such a device are:</p>
<ol>
<li>Support for <em>Wireless Client Mode</em> by the manufacturer&#8217;s firmware</li>
<li>Support for a <em>VPN Server</em> by the manufacturer&#8217;s firmware</li>
</ol>
<p>I know that these functions are available anyway if the DD-WRT firmware is used, but, if the default firmware supported these functions, it would definitely make a difference for me. Another useful feature would be the existence of a <em>USB port</em>, but this would greatly limit the available supported devices, so this is not a mandatory feature.</p>
<p>So, if anyone has a suggestion for such a router or if you own one, please let me know about your experience with it. I am particularly interested for devices that are 100% supported by the DD-WRT open source firmware.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2011/03/28/dd-wrt-support-for-wireless-n-routers/">DD-WRT support for Wireless N Routers</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2008/01/24/viceo-backend-for-sane-with-libusb-support/" rel="bookmark">Viceo Backend for SANE with libusb support</a></li>
<li><a href="http://www.g-loaded.eu/2010/04/16/software-that-detects-violations-of-open-source-licenses/" rel="bookmark">Software that detects violations of open source licenses</a></li>
<li><a href="http://www.g-loaded.eu/2008/12/08/creative-pc-cam-750-on-fedora-10/" rel="bookmark">Creative PC-CAM 750 on Fedora 10</a></li>
<li><a href="http://www.g-loaded.eu/2005/10/30/creative-pc-cam-750/" rel="bookmark">Creative PC-CAM Series webcams in linux</a></li>
<li><a href="http://www.g-loaded.eu/2006/12/19/howto-dhcp-server-dhcpd-configuration/" rel="bookmark">Howto: DHCP Server (dhcpd) Configuration</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2011/03/28/dd-wrt-support-for-wireless-n-routers/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Caching Nameserver using dnsmasq</title>
		<link>http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/</link>
		<comments>http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/#comments</comments>
		<pubDate>Fri, 17 Sep 2010 21:44:25 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Service]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=1907</guid>
		<description><![CDATA[dnsmasq is a lightweight, open-source DNS forwarder and DHCP server. In this article we go through how to prepare the system in order to run dnsmasq and also how to configure the latter as a caching-only DNS server. A configuration file is also provided as a drop-in replacement for the default dnsmasq.conf that ships with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">dnsmasq</a> is a lightweight, open-source DNS forwarder and DHCP server. In this article we go through how to prepare the system in order to run <em>dnsmasq</em> and also how to configure the latter as a <strong>caching-only</strong> <abbr title="Domain Name System">DNS</abbr> server. A configuration file is also provided as a drop-in replacement for the default <code>dnsmasq.conf</code> that ships with your system. dnsmasq is available in most Linux distributions. This article was written while using CentOS, so it is safe to say that it also fully covers RHEL, Fedora and generally the whole Red Hat family of operating systems and possibly Novell&#8217;s SLES and OpenSUSE. Small modifications of the invoked commands may be needed for Debian, Ubuntu and other systems.<br />
<span id="more-1907"></span></p>
<h4>Is a caching nameserver really important?</h4>
<p>There is some controversy about the real benefits of using a caching name server in a system, either desktop or server. In this article we keep controversy out of the discussion and focus on the performance improvement the caching of DNS information can offer to a system while performing specific tasks. For instance, a caching nameserver allows a web browser to acquire DNS information from the local DNS cache, provided that this information has already been cached, without the need to access any public DNS servers, which results in faster web browsing. Similarly, in a server environment, services like spam filters often need to perform many DNS queries for the same hostnames. The latency of the communication with the remote nameserver may add up to the total time of email processing.</p>
<h4>BIND vs dnsmasq</h4>
<p><em>BIND</em> is the flagship of DNS servers with large deployments around the globe. I have used BIND for many years as  a <strong>caching nameserver</strong>, even on my desktop, until I realized it is overkill to use BIND this way. There are lighter solutions, even all-in-one software like <strong>dnsmasq</strong>, that seem to be more suitable for setting up local DNS caching.</p>
<h4>System preparation</h4>
<p>So, let&#8217;s get started with the system preparation before going into the details of the dnsmasq configuration.</p>
<p>First of all, we need to install dnsmasq:</p>
<pre class="console">yum install dnsmasq</pre>
<p>dnsmasq, when run as <code>root</code>, is designed to <em>drop privileges</em> and run as an unprivileged user. By default, this user is <code>nobody</code>. We use a dedicated system user to run dnsmasq.</p>
<p>Run the following commands as <code>root</code> to create such an unprivileged system user and group named <em>dnsmasq</em>:</p>
<pre class="console">
groupadd -r dnsmasq
useradd -r -g dnsmasq dnsmasq
</pre>
<p>The above should be enough.</p>
<h4>Configuration</h4>
<p>All dnsmasq configuration options go into <code>/etc/dnsmasq.conf</code>. Here we write this file from scratch, so if you need to keep a copy of the original that ships with your distribution, do so with:</p>
<pre class="console">
cp /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
</pre>
<p>Now, let&#8217;s get started with adding our own dnsmasq configuration in <code>/etc/dnsmasq.conf</code>.</p>
<p>First of all, we set some options regarding the <strong>basic server operation</strong> like the interface and port on which it should bind, the unprivileged user that should run the service and a <abbr title="Process ID">PID</abbr> file:</p>
<pre class="codesnp">
listen-address=127.0.0.1
port=53
bind-interfaces
user=dnsmasq
group=dnsmasq
pid-file=/var/run/dnsmasq.pid
</pre>
<p>The <strong>bind-interfaces</strong> directive instructs dnsmasq to bind only to the network interface specified in the <strong>listen-address</strong> directive.</p>
<p>Next comes <strong>logging</strong>.</p>
<p>By default, dnsmasq sends its log messages to the <em>DAEMON</em> syslog facility (<em>LOCAL0</em> when operating in debug mode). We go with the defaults here, but keep in mind that a separate log file can be set as it is shown in the configuration snippet below (currently commented out):</p>
<pre class="codesnp">
#log-facility=/var/log/dnsmasq.log
#log-queries
</pre>
<p>Logging to file requires some extra configuration for proper log rotation. For more information, please read <a href="#LoggingToFile">Appendix II</a>.</p>
<p>Finally, we set the options that configure dnsmasq&#8217;s <strong>name resolution</strong> and <strong>caching</strong> operations.</p>
<p>The following directives prevent dnsmasq from forwarding plain names (without any dots) or addresses in the non-routed address space to the parent nameservers.</p>
<pre class="codesnp">
domain-needed
bogus-priv
</pre>
<p>The <strong>no-hosts</strong> directive also instructs dnsmasq not to read any hostnames from <code>/etc/hosts</code>. In most systems, <code>/etc/hosts</code> is queried before a DNS service is used by the system for name lookups. So, all plain name to private IP mappings should normally be added in <code>/etc/hosts</code>. If this is not what you want, then take a look at the <em>expand-hosts</em> and <em>domain</em> directives.</p>
<pre class="codesnp">
no-hosts
</pre>
<p>Set the maximum number of <strong>concurrent DNS queries</strong>. The default value is 150. Adjust to your needs.</p>
<pre class="codesnp">
dns-forward-max=150
</pre>
<p>Set the <strong>size</strong> of the dnsmasq cache. The default is to keep 150 hostnames. By setting the cache size to 0 disables the feature (this is not what we really want). Again, adjust this value according to your needs.</p>
<pre class="codesnp">
cache-size=1000
</pre>
<p>The following directive controls whether negative caching should be enabled or not. Negative caching allows dnsmasq to remember &#8220;<em>no such domain</em>&#8221; answers from the parent nameservers, so it does not query for the same non-existent hostnames again and again. This is probably useful for spam filters or MTA services. By default, negative caching is enabled. To disable, un-comment the following directive.</p>
<pre class="codesnp">
#no-negcache
</pre>
<p>The <strong>neg-ttl</strong> directive sets a default <abbr title="Time-To-Live">TTL</abbr> value to add to negative replies from the parent nameservers, in case these replies do not contain TTL information. If neg-ttl is not set and a negative reply from a parent DNS server does not contain TTL information, then dnsmasq will not cache the reply. Here we set the default TTL to 3600 seconds. Again, adjust to your specific needs.</p>
<pre class="codesnp">
neg-ttl=3600
</pre>
<p>Here we use a separate file where dnsmasq reads the IPs of the parent nameservers from. The syntax is the same as in <code>/etc/resolv.conf</code>. We do this to facilitate the manipulation of the parent nameservers that should be used by dnsmasq by using, for example, an external script. The filename we use here is <code>resolv.dnsmasq</code>, but this can be changed to your liking. We also set the <strong>no-poll</strong> directive here to prevent dnsmasq from polling the &#8216;resolv&#8217; file for changes.</p>
<pre class="codesnp">
resolv-file=/etc/resolv.dnsmasq
no-poll
</pre>
<p>A full configuration file containing all the above configuration, which can can be used as a drop-in replacement of the default <code>/etc/dnsmasq.conf</code>, can be found in <a href="#FullConfigurationFile">Appendix I</a>.</p>
<h4>Upstream Nameservers</h4>
<p>We have used a separate file to store the IPs of the parent nameservers; that is <code>/etc/resolv.dnsmasq</code>. Using the same syntax as in <code>/etc/resolv.conf</code> add the nameserver IP addresses in resolv.dnsmasq. For example:</p>
<pre class="codesnp">
nameserver 192.168.0.252
nameserver 192.168.0.253
nameserver 192.168.0.254
</pre>
<p>Note that we still need to make a change in <code>/etc/resolv.conf</code> before the system starts using dnsmasq for domain name lookups. Read on&#8230;</p>
<h4>Starting dnsmasq</h4>
<p>In order to start dnsmasq, run as root:</p>
<pre class="console">
/etc/init.d/dnsmasq start
</pre>
<p>Check the syslog or the dnsmasq logfile (if used) for any error messages.</p>
<p>If everything seems to be OK, set the dnsmasq service to start on boot:</p>
<pre class="console">
chkconfig dnsmasq on
</pre>
<p>This command might be Red-Hat specific, so consult your distribution&#8217;s documentation about how to set services to start on boot.</p>
<h4>Switch name resolution to dnsmasq</h4>
<p>What we have done so far is set up the dnsmasq service. For hostnames that do not exist in <code>/etc/hosts</code> the system still uses the nameserver inside <code>/etc/resolv.conf</code> for name resolution.</p>
<p>To start using dnsmasq, edit <code>/etc/resolv.conf</code>, remove all nameservers and add only the IP of our dnsmasq service:</p>
<pre class="codesnp">
nameserver 127.0.0.1
</pre>
<p>From now on, the system will use dnsmasq for domain name resolution. You can un-comment the <strong>log-queries</strong> option in order to confirm the dnsmasq operation.</p>
<h4 id="FullConfigurationFile">Appendix I &#8211; Full configuration file</h4>
<p>This is the complete configuration file containing the configuration that has been discussed in this article. Note that it can be used as is to replace the default <code>/etc/dnsmasq.conf</code>.</p>
<pre class="codesnp">
#
# Configuration file for dnsmasq acting as a caching nameserver.
#
# Format is one option per line, legal options are the same
# as the long options legal on the command line. See
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
#
# Updated versions of this configuration file may be available at:
#
#   http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/
#
#
# Basic server configuration
#
listen-address=127.0.0.1
port=53
bind-interfaces
user=dnsmasq
group=dnsmasq
pid-file=/var/run/dnsmasq.pid
#
# Logging
#
#log-facility=/var/log/dnsmasq.log
#log-queries
#
# Name resolution options
#
domain-needed
bogus-priv
no-hosts
dns-forward-max=150
cache-size=1000
#no-negcache
neg-ttl=3600
resolv-file=/etc/resolv.dnsmasq
no-poll
</pre>
<p>This file is meant to be used both on servers and desktops.</p>
<h4 id="LoggingToFile" >Appendix II &#8211; Logging to file</h4>
<p>Before dnsmasq starts logging to file it is required to set the path to the logfile in the <strong>log-facility</strong> option inside <code>/etc/dnsmasq.conf</code>.</p>
<pre class="codesnp">
log-facility=/var/log/dnsmasq.log
</pre>
<p>To ensure proper rotation of the log file you should use the following logrotate configuration:</p>
<pre class="codesnp">
/var/log/dnsmasq.log {
    monthly
    missingok
    notifempty
    delaycompress
    sharedscripts
    postrotate
        [ ! -f /var/run/dnsmasq.pid ] || kill -USR2 `cat /var/run/dnsmasq.pid`
    endscript
    create 0640 dnsmasq dnsmasq
}
</pre>
<p>Save the above configuration in <code>/etc/logrotate.d/dnsmasq</code>. Also, adjust the log filename or the path to the PID file in case you have used custom names, but make sure you do not change the <strong>USR2</strong> signal that is sent to the dnsmasq process in the post-rotation script.</p>
<h4>Final Thoughts</h4>
<p><strong>dnsmasq</strong> is a very lightweight service. Therefore, you can run it on any system, either server or desktop without any noticeable impact on system resources. In this guide we used it as an internal system service bound to the loopback interface, without permitting direct access from the outside. This along with the fact that dnsmasq is mature software that has been around for several years makes our setup rather secure.</p>
<p>Several people might argue that the performance improvement a local caching nameserver offers in terms of name lookup speed is insignificant. This might be true in some cases, but there are times that this performance improvement is noticeable, especially when the quality of the network connectivity between the current machine and the upstream nameserver is an issue, or when the upstream name server is overloaded. On the other hand, it is almost certain that a local caching DNS server can in no way make name resolution slower, unless perhaps a huge cache is being used. Generally, I find keeping such a service operational a good idea.</p>
<p>In this article we discussed about one of the dnsmasq features: DNS caching. dnsmasq is a lot more than just that. Check the whole feature set in the <a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">dnsmasq homepage</a>. Perhaps, in the future, more guides covering other features of this software are published. Until then, enjoy local DNS caching!!!</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/">Caching Nameserver using dnsmasq</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2008/12/02/set-up-an-anonymous-ftp-server-with-vsftpd-in-less-than-a-minute/" rel="bookmark">Set up an anonymous FTP server with vsftpd in less than a minute</a></li>
<li><a href="http://www.g-loaded.eu/2006/09/25/how-to-integrate-seaudit-report-in-logwatch/" rel="bookmark">How to integrate seaudit-report in logwatch</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/05/assign-virtual-ips-to-your-nic/" rel="bookmark">Assign Virtual IPs to your NIC</a></li>
<li><a href="http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/" rel="bookmark">Use wget or curl to download from RapidShare Premium</a></li>
<li><a href="http://www.g-loaded.eu/2007/08/10/ssl-enabled-name-based-apache-virtual-hosts-with-mod_gnutls/" rel="bookmark">SSL-enabled Name-based Apache Virtual Hosts with mod_gnutls</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>ping.py &#8211; Python Implementation of the ping command</title>
		<link>http://www.g-loaded.eu/2009/10/30/python-ping/</link>
		<comments>http://www.g-loaded.eu/2009/10/30/python-ping/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 18:54:18 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Snippet]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=1408</guid>
		<description><![CDATA[I&#8217;ve been looking for a pure python implementation of the ping command. Now that I found one, I am not sure if I want to use it, as it has a restriction: only privileged users can ping other hosts. I&#8217;ve used the ping command successfully as a normal user on all operating systems I have [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking for a pure python implementation of the <strong>ping</strong> command. Now that I found one, I am not sure if I want to use it, as it has a <em>restriction</em>: only privileged users can ping other hosts. I&#8217;ve used the ping command successfully as a normal user on all operating systems I have tried and never had an issue. Currently, I do not have the time to investigate this limitation, but, judging by the exception I get, it has to do with the creation of the socket through which the ICMP packet is sent. The normal user does not have the required privileges to create this socket.</p>
<p>[This post has been updated]<br />
<span id="more-1408"></span><br />
[<strong>Update #1</strong>]: This limitation also exists on the <strong>ping</strong> command, which runs with <strong>setuid</strong> access rights. (Thanks <a href="http://www.sakana.fr/blog/">Stephane</a>)</p>
<p>[<strong>Update #2</strong>]: After <a href="http://cdhallman.blogspot.com">Chris Hallman</a> reported that the original code actually works on Windows only, I made some changes to it and publish the updated code below.</p>
<p>The following code is a pure <strong>Python</strong> implementation of the <strong>ping</strong> command. I originally found it in the <a href="http://trac.pylucid.net/browser/CodeSnippets/ping.py">source code tree of pylucid</a> in a subdirectory where the developers keep various code snippets.</p>
<p>I had originally tested the code under Microsoft Windows as this was the OS I had available at the moment.  Chris Hallman noticed that the code does not work under GNU/Linux. After spending some hours trying to figure out what was wrong it, I realized that the part of the code that caused the failure on Linux was the use of the <code>time.clock()</code> function instead of <code>time.time()</code>. The <code>clock()</code> method works <a href="http://docs.python.org/library/time.html#time.clock">differently</a> under Windows and Linux.</p>
<p>I fixed the 2007 implementation and hereby publish the updated code(as <a href="http://www.g-loaded.eu/2009/10/30/python-ping/">python-ping</a>). Feel free to test it and report any issues.</p>
<p>Needed: test on Solaris.</p>
<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
&nbsp;
<span style="color: #483d8b;">&quot;&quot;&quot;
    A pure python ping implementation using raw socket.
&nbsp;
&nbsp;
    Note that ICMP messages can only be sent from processes running as root.
&nbsp;
&nbsp;
    Derived from ping.c distributed in Linux's netkit. That code is
    copyright (c) 1989 by The Regents of the University of California.
    That code is in turn derived from code written by Mike Muuss of the
    US Army Ballistic Research Laboratory in December, 1983 and
    placed in the public domain. They have my thanks.
&nbsp;
    Bugs are naturally mine. I'd be glad to hear about them. There are
    certainly word - size dependenceies here.
&nbsp;
    Copyright (c) Matthew Dixon Cowles, &lt;http://www.visi.com/~mdc/&gt;.
    Distributable under the terms of the GNU General Public License
    version 2. Provided with no warranties of any sort.
&nbsp;
    Original Version from Matthew Dixon Cowles:
      -&gt; ftp://ftp.visi.com/users/mdc/ping.py
&nbsp;
    Rewrite by Jens Diemer:
      -&gt; http://www.python-forum.de/post-69122.html#69122
&nbsp;
    Rewrite by George Notaras:
      -&gt; http://www.g-loaded.eu/2009/10/30/python-ping/
&nbsp;
    Revision history
    ~~~~~~~~~~~~~~~~
&nbsp;
    November 8, 2009
    ----------------
    Improved compatibility with GNU/Linux systems.
&nbsp;
    Fixes by:
     * George Notaras -- http://www.g-loaded.eu
    Reported by:
     * Chris Hallman -- http://cdhallman.blogspot.com
&nbsp;
    Changes in this release:
     - Re-use time.time() instead of time.clock(). The 2007 implementation
       worked only under Microsoft Windows. Failed on GNU/Linux.
       time.clock() behaves differently under the two OSes[1].
&nbsp;
    [1] http://docs.python.org/library/time.html#time.clock
&nbsp;
    May 30, 2007
    ------------
    little rewrite by Jens Diemer:
     -  change socket asterisk import to a normal import
     -  replace time.time() with time.clock()
     -  delete &quot;return None&quot; (or change to &quot;return&quot; only)
     -  in checksum() rename &quot;str&quot; to &quot;source_string&quot;
&nbsp;
    November 22, 1997
    -----------------
    Initial hack. Doesn't do much, but rather than try to guess
    what features I (or others) will want in the future, I've only
    put in what I need now.
&nbsp;
    December 16, 1997
    -----------------
    For some reason, the checksum bytes are in the wrong order when
    this is run under Solaris 2.X for SPARC but it works right under
    Linux x86. Since I don't know just what's wrong, I'll swap the
    bytes always and then do an htons().
&nbsp;
    December 4, 2000
    ----------------
    Changed the struct.pack() calls to pack the checksum and ID as
    unsigned. My thanks to Jerome Poincheval for the fix.
&nbsp;
&nbsp;
    Last commit info:
    ~~~~~~~~~~~~~~~~~
    $LastChangedDate: $
    $Rev: $
    $Author: $
&quot;&quot;&quot;</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>, <span style="color: #dc143c;">sys</span>, <span style="color: #dc143c;">socket</span>, <span style="color: #dc143c;">struct</span>, <span style="color: #dc143c;">select</span>, <span style="color: #dc143c;">time</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># From /usr/include/linux/icmp.h; your milage may vary.</span>
ICMP_ECHO_REQUEST = <span style="color: #ff4500;">8</span> <span style="color: #808080; font-style: italic;"># Seems to be the same on Solaris.</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> checksum<span style="color: black;">&#40;</span>source_string<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;
    I'm not too confident that this is right but testing seems
    to suggest that it gives the same answers as in_cksum in ping.c
    &quot;&quot;&quot;</span>
    <span style="color: #008000;">sum</span> = <span style="color: #ff4500;">0</span>
    countTo = <span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>source_string<span style="color: black;">&#41;</span>/<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #ff4500;">2</span>
    count = <span style="color: #ff4500;">0</span>
    <span style="color: #ff7700;font-weight:bold;">while</span> count<span style="color: #66cc66;">&lt;</span>countTo:
        thisVal = <span style="color: #008000;">ord</span><span style="color: black;">&#40;</span>source_string<span style="color: black;">&#91;</span>count + <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #ff4500;">256</span> + <span style="color: #008000;">ord</span><span style="color: black;">&#40;</span>source_string<span style="color: black;">&#91;</span>count<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">sum</span> = <span style="color: #008000;">sum</span> + thisVal
        <span style="color: #008000;">sum</span> = <span style="color: #008000;">sum</span> <span style="color: #66cc66;">&amp;</span> 0xffffffff <span style="color: #808080; font-style: italic;"># Necessary?</span>
        count = count + <span style="color: #ff4500;">2</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> countTo<span style="color: #66cc66;">&lt;</span>len<span style="color: black;">&#40;</span>source_string<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">sum</span> = <span style="color: #008000;">sum</span> + <span style="color: #008000;">ord</span><span style="color: black;">&#40;</span>source_string<span style="color: black;">&#91;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>source_string<span style="color: black;">&#41;</span> - <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">sum</span> = <span style="color: #008000;">sum</span> <span style="color: #66cc66;">&amp;</span> 0xffffffff <span style="color: #808080; font-style: italic;"># Necessary?</span>
&nbsp;
    <span style="color: #008000;">sum</span> = <span style="color: black;">&#40;</span><span style="color: #008000;">sum</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">16</span><span style="color: black;">&#41;</span>  +  <span style="color: black;">&#40;</span><span style="color: #008000;">sum</span> <span style="color: #66cc66;">&amp;</span> 0xffff<span style="color: black;">&#41;</span>
    <span style="color: #008000;">sum</span> = <span style="color: #008000;">sum</span> + <span style="color: black;">&#40;</span><span style="color: #008000;">sum</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">16</span><span style="color: black;">&#41;</span>
    answer = ~<span style="color: #008000;">sum</span>
    answer = answer <span style="color: #66cc66;">&amp;</span> 0xffff
&nbsp;
    <span style="color: #808080; font-style: italic;"># Swap bytes. Bugger me if I know why.</span>
    answer = answer <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">8</span> | <span style="color: black;">&#40;</span>answer <span style="color: #66cc66;">&lt;&lt;</span> <span style="color: #ff4500;">8</span> <span style="color: #66cc66;">&amp;</span> 0xff00<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">return</span> answer
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> receive_one_ping<span style="color: black;">&#40;</span>my_socket, ID, timeout<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;
    receive the ping from the socket.
    &quot;&quot;&quot;</span>
    timeLeft = timeout
    <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
        startedSelect = <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        whatReady = <span style="color: #dc143c;">select</span>.<span style="color: #dc143c;">select</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>my_socket<span style="color: black;">&#93;</span>, <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>, <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>, timeLeft<span style="color: black;">&#41;</span>
        howLongInSelect = <span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> - startedSelect<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> whatReady<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>: <span style="color: #808080; font-style: italic;"># Timeout</span>
            <span style="color: #ff7700;font-weight:bold;">return</span>
&nbsp;
        timeReceived = <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        recPacket, addr = my_socket.<span style="color: black;">recvfrom</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1024</span><span style="color: black;">&#41;</span>
        icmpHeader = recPacket<span style="color: black;">&#91;</span><span style="color: #ff4500;">20</span>:<span style="color: #ff4500;">28</span><span style="color: black;">&#93;</span>
        <span style="color: #008000;">type</span>, <span style="color: #dc143c;">code</span>, checksum, packetID, sequence = <span style="color: #dc143c;">struct</span>.<span style="color: black;">unpack</span><span style="color: black;">&#40;</span>
            <span style="color: #483d8b;">&quot;bbHHh&quot;</span>, icmpHeader
        <span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> packetID == ID:
            bytesInDouble = <span style="color: #dc143c;">struct</span>.<span style="color: black;">calcsize</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;d&quot;</span><span style="color: black;">&#41;</span>
            timeSent = <span style="color: #dc143c;">struct</span>.<span style="color: black;">unpack</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;d&quot;</span>, recPacket<span style="color: black;">&#91;</span><span style="color: #ff4500;">28</span>:<span style="color: #ff4500;">28</span> + bytesInDouble<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
            <span style="color: #ff7700;font-weight:bold;">return</span> timeReceived - timeSent
&nbsp;
        timeLeft = timeLeft - howLongInSelect
        <span style="color: #ff7700;font-weight:bold;">if</span> timeLeft <span style="color: #66cc66;">&lt;</span>= <span style="color: #ff4500;">0</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> send_one_ping<span style="color: black;">&#40;</span>my_socket, dest_addr, ID<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;
    Send one ping to the given &gt;dest_addr&lt;.
    &quot;&quot;&quot;</span>
    dest_addr  =  <span style="color: #dc143c;">socket</span>.<span style="color: black;">gethostbyname</span><span style="color: black;">&#40;</span>dest_addr<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;"># Header is type (8), code (8), checksum (16), id (16), sequence (16)</span>
    my_checksum = <span style="color: #ff4500;">0</span>
&nbsp;
    <span style="color: #808080; font-style: italic;"># Make a dummy heder with a 0 checksum.</span>
    header = <span style="color: #dc143c;">struct</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;bbHHh&quot;</span>, ICMP_ECHO_REQUEST, <span style="color: #ff4500;">0</span>, my_checksum, ID, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
    bytesInDouble = <span style="color: #dc143c;">struct</span>.<span style="color: black;">calcsize</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;d&quot;</span><span style="color: black;">&#41;</span>
    data = <span style="color: black;">&#40;</span><span style="color: #ff4500;">192</span> - bytesInDouble<span style="color: black;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #483d8b;">&quot;Q&quot;</span>
    data = <span style="color: #dc143c;">struct</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;d&quot;</span>, <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> + data
&nbsp;
    <span style="color: #808080; font-style: italic;"># Calculate the checksum on the data and the dummy header.</span>
    my_checksum = checksum<span style="color: black;">&#40;</span>header + data<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;"># Now that we have the right checksum, we put that in. It's just easier</span>
    <span style="color: #808080; font-style: italic;"># to make up a new header than to stuff it into the dummy.</span>
    header = <span style="color: #dc143c;">struct</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span>
        <span style="color: #483d8b;">&quot;bbHHh&quot;</span>, ICMP_ECHO_REQUEST, <span style="color: #ff4500;">0</span>, <span style="color: #dc143c;">socket</span>.<span style="color: black;">htons</span><span style="color: black;">&#40;</span>my_checksum<span style="color: black;">&#41;</span>, ID, <span style="color: #ff4500;">1</span>
    <span style="color: black;">&#41;</span>
    packet = header + data
    my_socket.<span style="color: black;">sendto</span><span style="color: black;">&#40;</span>packet, <span style="color: black;">&#40;</span>dest_addr, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># Don't know about the 1</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> do_one<span style="color: black;">&#40;</span>dest_addr, timeout<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;
    Returns either the delay (in seconds) or none on timeout.
    &quot;&quot;&quot;</span>
    icmp = <span style="color: #dc143c;">socket</span>.<span style="color: black;">getprotobyname</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;icmp&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        my_socket = <span style="color: #dc143c;">socket</span>.<span style="color: #dc143c;">socket</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">socket</span>.<span style="color: black;">AF_INET</span>, <span style="color: #dc143c;">socket</span>.<span style="color: black;">SOCK_RAW</span>, icmp<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #dc143c;">socket</span>.<span style="color: black;">error</span>, <span style="color: black;">&#40;</span><span style="color: #dc143c;">errno</span>, msg<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">errno</span> == <span style="color: #ff4500;">1</span>:
            <span style="color: #808080; font-style: italic;"># Operation not permitted</span>
            msg = msg + <span style="color: black;">&#40;</span>
                <span style="color: #483d8b;">&quot; - Note that ICMP messages can only be sent from processes&quot;</span>
                <span style="color: #483d8b;">&quot; running as root.&quot;</span>
            <span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #dc143c;">socket</span>.<span style="color: black;">error</span><span style="color: black;">&#40;</span>msg<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #808080; font-style: italic;"># raise the original error</span>
&nbsp;
    my_ID = <span style="color: #dc143c;">os</span>.<span style="color: black;">getpid</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span> 0xFFFF
&nbsp;
    send_one_ping<span style="color: black;">&#40;</span>my_socket, dest_addr, my_ID<span style="color: black;">&#41;</span>
    delay = receive_one_ping<span style="color: black;">&#40;</span>my_socket, my_ID, timeout<span style="color: black;">&#41;</span>
&nbsp;
    my_socket.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> delay
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> verbose_ping<span style="color: black;">&#40;</span>dest_addr, timeout = <span style="color: #ff4500;">2</span>, count = <span style="color: #ff4500;">4</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;
    Send &gt;count&lt; ping to &gt;dest_addr&lt; with the given &gt;timeout&lt; and display
    the result.
    &quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span>count<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;ping %s...&quot;</span> <span style="color: #66cc66;">%</span> dest_addr,
        <span style="color: #ff7700;font-weight:bold;">try</span>:
            delay  =  do_one<span style="color: black;">&#40;</span>dest_addr, timeout<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #dc143c;">socket</span>.<span style="color: black;">gaierror</span>, e:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;failed. (socket error: '%s')&quot;</span> <span style="color: #66cc66;">%</span> e<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
            <span style="color: #ff7700;font-weight:bold;">break</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">if</span> delay  ==  <span style="color: #008000;">None</span>:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;failed. (timeout within %ssec.)&quot;</span> <span style="color: #66cc66;">%</span> timeout
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            delay  =  delay <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">1000</span>
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;get ping in %0.4fms&quot;</span> <span style="color: #66cc66;">%</span> delay
    <span style="color: #ff7700;font-weight:bold;">print</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    verbose_ping<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;heise.de&quot;</span><span style="color: black;">&#41;</span>
    verbose_ping<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;google.com&quot;</span><span style="color: black;">&#41;</span>
    verbose_ping<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;a-test-url-taht-is-not-available.com&quot;</span><span style="color: black;">&#41;</span>
    verbose_ping<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;192.168.1.1&quot;</span><span style="color: black;">&#41;</span></pre></div></div>
<p>I decided not to publish the updated code on <a href="http://www.codetrax.org">CodeTRAX</a>, where I normally publish any programming-related stuff, but leave it on <a href="http://www.g-loaded.eu">G-Loaded</a> instead.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2009/10/30/python-ping/">ping.py &#8211; Python Implementation of the ping command</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2006/05/06/sockets-programming-in-python/" rel="bookmark">Sockets Programming In Python</a></li>
<li><a href="http://www.g-loaded.eu/2009/05/07/descramble-passwords-from-gftp-bookmarks-using-python/" rel="bookmark">Descramble Passwords from gftp Bookmarks using Python</a></li>
<li><a href="http://www.g-loaded.eu/2007/01/31/python-irc-bot/" rel="bookmark">Python IRC Bot</a></li>
<li><a href="http://www.g-loaded.eu/2006/09/23/use-python-to-get-the-web-page-data-in-epiphany/" rel="bookmark">Use Python to get the web page data in Epiphany</a></li>
<li><a href="http://www.g-loaded.eu/2006/04/07/python-crash-course/" rel="bookmark">Python Crash Course</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2009/10/30/python-ping/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Xen DomU using dynamic IP and hostname</title>
		<link>http://www.g-loaded.eu/2009/02/01/xen-domu-using-dynamic-ip-and-hostname/</link>
		<comments>http://www.g-loaded.eu/2009/02/01/xen-domu-using-dynamic-ip-and-hostname/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 14:16:43 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[DHCP]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[Xen]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=845</guid>
		<description><![CDATA[During the last months, I&#8217;ve been experimenting with Xen virtualization. An old computer, equipped with a Pentium III running at 700Mhz, 512MB of RAM and an 160GB IDE HDD runs four installations of my favorite Linux distribution, CentOS, one as a Dom0 and the other three as DomUs with 64MB of memory each. I remember [...]]]></description>
			<content:encoded><![CDATA[<p>During the last months, I&#8217;ve been experimenting with <a href="http://www.xen.org/">Xen</a> virtualization. An old computer, equipped with a <em>Pentium III</em> running at 700Mhz, 512MB of <em>RAM</em> and an 160GB <em>IDE</em> HDD runs <strong>four</strong> installations of my <em>favorite</em> Linux distribution, <a href="http://centos.org/">CentOS</a>, one as a <a href="http://wiki.xensource.com/xenwiki/Dom0">Dom0</a> and the other three as <a href="http://wiki.xensource.com/xenwiki/DomU">DomU</a>s with 64MB of memory each.<br />
<span id="more-845"></span><br />
I remember that one of the first things I needed to test was whether all those virtual machines could properly use my <strong>DHCP</strong> service, located on a separate machine within my <strong>LAN</strong>, and get a <em>dynamic IP</em>. Furthermore, each time <strong>dhclient</strong> ran on the Dom0 or any of the DomUs in order to obtain a dynamic IP address, it also sent a name (non <em>FQDN</em>) to the DHCP service. This name represented the name the machine wished to use as a <strong>hostname</strong>. The DHCP server should generate an <em>FQDN</em> out of that name and update the <em>forward</em> and <em>reverse zones</em> on the <strong>DNS</strong> server, so that each virtual machine&#8217;s <em>FQDN</em> name could properly resolve to the relevant IP address, which had been allocated to the <abbr title="Virtual Machine">VM</abbr> by the <em>DHCP</em> service. All this had already been set up in my home LAN since a long time ago, but had never actually tested it with multiple computers or other devices and virtualization definitely provided me with this option.</p>
<p>While I was performing the operating system installations, everything seemed to work as expected. Each virtual machine obtained a <strong>dynamic IP</strong> address and the <strong>DNS records</strong> were updated correctly. Glad that things work, I turned off Dom0 after the tests.</p>
<p>At a later time, when I switched <em>Dom0</em> on again, I noticed that I <strong>could not reach any of the virtual machines</strong>. Their fully qualified domain names that had been allocated to them by the DHCP service would not resolve to the proper IP. To make it worse, it seemed that the virtual machines had no active leases at all!</p>
<p>Soon I discovered that <strong>xendomains</strong>, the service responsible for starting and stopping the unprivileged Xen domains (DomU), whenever Domain Zero was shut down, it just <strong>saved</strong> the domain U&#8217;s state for later restoration instead of initiating the DomU&#8217;s shutdown procedure. When Dom0 was brought up again, <em>xendomains</em> <strong>restored</strong> the saved DomU states instead of forcing the domains to boot up normally.</p>
<p>I assume this is like suspending a laptop, which has obtained its IP automatically from a DHCP service within LAN A, moving it to a LAN B, and then bringing it up again within that LAN. It is almost certain that for an arbitrary amount of time you would experience connectivity problems.</p>
<p>In both cases above, at the time the machine resumes operations, the <strong>dhclient</strong> script (or any other similar script) is not run in order to <em>renew</em> the machine&#8217;s IP address.</p>
<p>Fortunately, this behaviour of the <code>xendomains</code> service is configurable. In order to force all DomUs to shutdown, instead of suspending, during Domain 0&#8242;s shutdown, all you have to do is make following changes in <code>/etc/sysconfig/xendomains</code>:</p>
<p>Leave empty the XENDOMAINS_SAVE variable. By default, it uses /var/lib/xen/save as the directory where the states of the DomUs are saved. By leaving it empty, the states of the virtual machines are not saved, but they are shut down as usual.</p>
<pre class="codesnp">
XENDOMAINS_SAVE=""
</pre>
<p>The second modification involves setting the XENDOMAINS_RESTORE variable to false. This determines whether saved domains will be restored from the directory set in the XENDOMAINS_SAVE variable during the Dom0 startup:</p>
<pre class="codesnp">
XENDOMAINS_RESTORE=false
</pre>
<p>From now on, whenever Dom0 starts up, it will force all U domains to boot up normally. Contrariwise, whenever Dom0 shuts down, it will force all DomU to shut down as well. No domain state saving or restoration happens any more.</p>
<p>This means that the network service on each DomU, hence the <em>dhclient</em> script, will run <strong>every time</strong> the domain U starts up or shuts down, <strong>ensuring proper allocation of dynamic IP addresses and hostnames</strong> by the DHCP service. Of course, this adds much overhead to both the boot and power off process of Domain Zero (Dom0), but it seems that there is no other way to overcome this problem. If you know of a better way, please let me know.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2009/02/01/xen-domu-using-dynamic-ip-and-hostname/">Xen DomU using dynamic IP and hostname</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2006/12/19/howto-dhcp-server-dhcpd-configuration/" rel="bookmark">Howto: DHCP Server (dhcpd) Configuration</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/05/assign-virtual-ips-to-your-nic/" rel="bookmark">Assign Virtual IPs to your NIC</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/configure-vnc-server-in-fedora/" rel="bookmark">Set up the VNC Server in Fedora</a></li>
<li><a href="http://www.g-loaded.eu/2006/01/06/partition-images-with-partimage-and-partimaged/" rel="bookmark">Partition images with Partimage and Partimaged</a></li>
<li><a href="http://www.g-loaded.eu/2008/12/10/almost-saying-goodbye-to-innovation/" rel="bookmark">Almost saying goodbye to innovation</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2009/02/01/xen-domu-using-dynamic-ip-and-hostname/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Using SSH for networking</title>
		<link>http://www.g-loaded.eu/2008/05/16/using-ssh-for-networking/</link>
		<comments>http://www.g-loaded.eu/2008/05/16/using-ssh-for-networking/#comments</comments>
		<pubDate>Fri, 16 May 2008 00:13:02 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Servers]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=474</guid>
		<description><![CDATA[This is mainly a note to myself about two patches, just in case I ever decide to use OpenSSH for networking, in addition to remote administration. First, is the cipler-none patch that adds none as a valid argument to the -c command line option. By using it, the transferred data is not encrypted. Pros: eliminates [...]]]></description>
			<content:encoded><![CDATA[<p>This is mainly a note to myself about two patches, just in case I ever decide to use <a href="http://www.openssh.org/">OpenSSH</a> for networking, in addition to remote administration.</p>
<p><strong>First</strong>, is the <strong>cipler-none</strong> patch that adds <code>none</code> as a valid argument to the <strong>-c</strong> command line option. By using it, the transferred data is not encrypted. <em>Pros</em>: eliminates the data encryption overhead. <em>Cons</em>: totally insecure method of transferring sensitive data.</p>
<p><a href="http://arctic.org/~dean/patches/openssh-3.8.1p1-cipher-none.patch">cipher-none-patch</a></p>
<p><em>Note</em>: the OpenSSH server, even if it has been patched with this code, does not accept unencrypted connections by default. This has to be enabled explicitly in the sshd configuration (<code>sshd_config</code>) by adding the <em>none</em> &#8220;cipher&#8221; to the list of the accepted ciphers:</p>
<pre class="codesnp">Ciphers aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr,none</pre>
<p><em>Note2</em>: here is <em>step-by-step</em> guide how to configure the <em><a href="http://www.g-loaded.eu/2005/11/10/ssh-with-keys/">SSH authentication using public keys</a></em>.</p>
<p><strong>Second</strong>, is a set of patches, created at the <a href="http://www.psc.edu/">Pittsburgh Supercomputing Center</a>, which eliminate the bottlenecks caused by some of the internal buffers that control data flow in network connections through OpenSSH. This project is called <a href="http://www.psc.edu/networking/projects/hpn-ssh/">High Performance SSH/SCP</a> (aka <em>HPN-SSH</em>). Benchmarks show that even encrypted network connections using HPN-SSH perform extraordinarily better than the usual encrypted OpenSSH connections.</p>
<p>OK, this info exists here for completeness, as those HPN-SSH patches <em>have not been designed for home networks</em>! Possibly it might make no difference if you use the regular OpenSSH or HPN-SSH in your home LAN.</p>
<p><em>Note</em>: the HPN-SSH patches also contain code that adds the <em>none</em> cipher, similar to the <em>cipher-none patch</em>, so, if you intend to use HPN-SSH, it is not required to apply both on the OpenSSH source.</p>
<p>Finally, apart from all these, if you ever decide to use SSH for networking seriously consider using <a href="http://fuse.sourceforge.net/sshfs.html">SSHfs</a> (see also <a href="http://fuse.sourceforge.net/wiki/index.php/SshfsFaq">SSHfsFAQ</a>).</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2008/05/16/using-ssh-for-networking/">Using SSH for networking</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2011/09/27/mod_gnutls-rc4-cipher-beast/" rel="bookmark">How to configure mod_gnutls to use the RC4 cipher to mitigate the SSL/TLS vulnerability</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/05/assign-virtual-ips-to-your-nic/" rel="bookmark">Assign Virtual IPs to your NIC</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/ssh-with-keys/" rel="bookmark">Setup the SSH server to use keys for authentication</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/encrypt-devices-using-dm-crypt-and-luks/" rel="bookmark">Encrypt devices using dm-crypt and LUKS</a></li>
<li><a href="http://www.g-loaded.eu/2006/11/05/truecrypt-on-2618-kernels/" rel="bookmark">TrueCrypt on 2.6.18 kernels</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2008/05/16/using-ssh-for-networking/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>How to Disable IPv6 in Fedora and CentOS</title>
		<link>http://www.g-loaded.eu/2008/05/12/how-to-disable-ipv6-in-fedora-and-centos/</link>
		<comments>http://www.g-loaded.eu/2008/05/12/how-to-disable-ipv6-in-fedora-and-centos/#comments</comments>
		<pubDate>Mon, 12 May 2008 19:31:41 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Servers]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=477</guid>
		<description><![CDATA[They say that by disabling IPv6 things get a bit smoother and faster regarding networking. I don&#8217;t really know if this is true, but I guess, if you&#8217;ve decided to disable this feature, you probably care to do it the Right Way&#8482;. As far as I know, trying to disable IPv6 through anaconda during the [...]]]></description>
			<content:encoded><![CDATA[<p>They say that by disabling <a href="http://en.wikipedia.org/wiki/Ipv6">IPv6</a> things get a bit smoother and faster regarding networking. I don&#8217;t really know if this is true, but I guess, if you&#8217;ve decided to disable this feature, you probably care to do it the Right Way&trade;. As far as I know, trying to disable IPv6 through anaconda during the installation of Fedora or CentOS does not turn off the IPv6 functionality completely, but it just disables it for the configured network interface. This is not actually a problem, but, why should this network layer be enabled system-wide, if you do not use it at all? This small article assists you in disabling IPv6 in the latest <a href="http://fedoraproject.org/">Fedora</a> and <a href="http://centos.org/">CentOS</a> releases in an <em>aggressive</em> and <em>unforgiving</em> way.<br />
<span id="more-477"></span></p>
<h4>Check if the module is loaded</h4>
<p>IPv6 functionality is being made available to the system by the <strong>ipv6</strong> <em>kernel module</em>. To check if this module is currently loaded in your system, issue the following command as <em>root</em>:</p>
<pre class="console">
lsmod | grep ipv6
</pre>
<p>If you see <code>ipv6</code> in its output, then the module is loaded.</p>
<p>Performing this check is <em>absolutely not necessary</em>. It is included in this article for completeness.</p>
<h4>Disable IPv6</h4>
<p>You can prevent a module from being inserted into the kernel by either <strong>blacklisting</strong> it <em>or</em> by completely <strong>disabling</strong> it.</p>
<p>In this case, since you will most probably turn off the IPv6 firewall (<em>ip6tables</em>) as well, it is highly recommended to completely disable the ipv6 module, to avoid any accidental loading of the IPv6 stack without any firewall protection at the same time.</p>
<h5>How the module blacklist works</h5>
<p>This information about blacklisting a kernel module exists here for educational purposes. It has been mentioned above that for ipv6 it is important to completely disable it.</p>
<p>From the <code>modprobe.conf</code> man page:</p>
<blockquote><p>
Modules can contain their own aliases: usually these are aliases describing the devices  they  support,  such  as  &#8220;pci:123&#8230;&#8221;.   These  &#8220;internal&#8221; aliases  can  be  overridden  by  normal  &#8220;alias&#8221; keywords, but there are cases where two or more modules both support the same devices, or a module invalidly claims to support a device: the blacklist keyword indicates that all of that particular module’s internal aliases are to be ignored.
</p></blockquote>
<p>So, <strong>blacklist</strong> indicates that a module&#8217;s aliases should be ignored. But, what happens if an application requires to load that specific module or if root uses <code>modprobe</code> to load it on demand? Let&#8217;s test it&#8230;</p>
<p>To blacklist the module, simply save the following line in a file inside <code>/etc/modprobe.d</code>:</p>
<pre class="codesnp">
blacklist ipv6
</pre>
<p>Next, disable any services that use IPv6, eg <code>ip6tables</code> or any IPv6-enabled network interfaces and <strong>reboot</strong> (mandatory).</p>
<p>After you&#8217;ve logged-in again, try, for example, to load the ipv6 module with the <code>modprobe</code> command (as root):</p>
<pre class="console">
[root@centos]# modprobe -v ipv6
insmod /lib/modules/2.6.18-53.1.14.el5/kernel/net/ipv6/ipv6.ko
[root@centos]# lsmod | grep v6
ipv6                  251393  8
</pre>
<p>The blacklisted module has been loaded. This is what happens if it is needed by a system service, regardless of the fact that it has been blacklisted. In the case of <code>ipv6</code> this could be a security risk, provided that the ipv6 firewall has been turned off but some network interfaces still use IPv6. So, frankly, it is suggested to read on how to disable the module more aggressively&#8230;</p>
<h5>Completely disable the ipv6 module</h5>
<p>To completely disable IPv6 in your system, all you have to do is save the following line in a file inside <code>/etc/modprobe.d/</code>.</p>
<pre class="codesnp">
install ipv6 /bin/true
</pre>
<p>The above line means: whenever the system needs to load the <strong>ipv6</strong> kernel module, it is forced to execute the command <code>true</code> instead of actually loading the module. Since <code>/bin/true</code>, does absolutely nothing, the module <strong>never</strong> gets loaded.</p>
<p>Again, it is required to <strong>reboot</strong> for the changes to take effect.</p>
<p>It is obvious that this is an <em>aggressive</em> method to disable kernel modules, but it <strong>guarantees</strong> that the module never gets loaded.</p>
<p>This is the <strong>recommended</strong> way to <em>disable IPv6</em>.</p>
<h4>Other Configuration Tasks</h4>
<p>Since the IPv6 functionality has been disabled, you can disable the <strong>ip6tables</strong> service (IPv6 Firewall). Issue the following command as <em>root</em>:</p>
<pre class="console">
chkconfig ip6tables off
</pre>
<p>It is also a good idea, since the ip6tables service has been turned off, to disable any IPv6-related functionality in the network interface configuration. Even if you do not do this, the IPv6 stack will not be initialized because the <em>ipv6 module</em> cannot be loaded. But, generally, you could set the following options to &#8220;<strong>no</strong>&#8221; inside your network interface scripts, for example: <code>/etc/sysconfig/network-scripts/ifcfg-eth0</code></p>
<pre class="codesnp">
IPV6INIT=no
IPV6_AUTOCONF=no
</pre>
<p>Finally, In fedora 8 or newer you can safely remove the following option from the /etc/sysconfig/network file, if it exists:</p>
<pre class="codesnp">
NETWORKING_IPV6=no
</pre>
<h4>Final Thoughts</h4>
<p>Using the instructions above, you can completely disable IPv6 in your system. On the other hand, you should understand that IPv6 is not an evil thing&#8230; It exists in order to address certain issues. If you ever think about actually trying to configure and use it instead of just disabling it every time you install your Linux operating system, here is a <a href="http://fedoraproject.org/wiki/IPv6Guide">good place to start</a>&#8230;</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2008/05/12/how-to-disable-ipv6-in-fedora-and-centos/">How to Disable IPv6 in Fedora and CentOS</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2009/10/05/fedora-server-vs-centos/" rel="bookmark">Fedora Server vs CentOS</a></li>
<li><a href="http://www.g-loaded.eu/2005/12/14/the-complete-fedora-kernel-headers/" rel="bookmark">The Complete Fedora Kernel Headers</a></li>
<li><a href="http://www.g-loaded.eu/2008/12/08/creative-pc-cam-750-on-fedora-10/" rel="bookmark">Creative PC-CAM 750 on Fedora 10</a></li>
<li><a href="http://www.g-loaded.eu/2009/12/18/high-cpu-usage-centos-guest-virtualbox-vmware/" rel="bookmark">High CPU usage while running CentOS as guest on Virtualbox or VMware</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/configure-vnc-server-in-fedora/" rel="bookmark">Set up the VNC Server in Fedora</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2008/05/12/how-to-disable-ipv6-in-fedora-and-centos/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Use wget or curl to download from RapidShare Premium</title>
		<link>http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/</link>
		<comments>http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/#comments</comments>
		<pubDate>Sat, 15 Sep 2007 08:55:17 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Snippet]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/</guid>
		<description><![CDATA[This article describes how to use the command line download managers wget and curl in order to download files from your Rapidshare Premium account.]]></description>
			<content:encoded><![CDATA[<p>The last days I needed to download a bunch of medical videos which have been uploaded to RapidShare by many other people. Although RapidShare (and all the other 1-click file-hosting services) is very convenient, it has some strict rules for free accounts, for example a guest has to wait for 120 seconds per 1 MB of downloaded data and &#8211; to make it worse &#8211; no download managers are allowed. Since &#8220;waiting&#8221; is not a game I like and since I intended to use either <a href="http://www.gnu.org/software/wget/">wget</a> or <a href="http://curl.haxx.se/">curl</a> to download the files, I decided to sign up for a <a href="http://www.rapidshare.com/">RapidShare</a> Premium account and then figure out how to use the aforementioned tools. Fortunately, registered users are permitted to use download managers and, as you will read in the following article, the Linux command line downloaders work flawlessly with a Premier account.<br />
<span id="more-443"></span></p>
<h4>Theory</h4>
<p>Rapidshare uses cookie-based authentication. This means that every time you log into the service, a cookie containing information which identifies you as a registered user is stored in your browser&#8217;s cookie cache. Both <code>wget</code> and <code>curl</code> support saving and loading cookies, so before using them to download any files, you should save such a cookie. Having done this, then the only required action in order download from RapidShare is to load the cookie, so that wget or curl can use it to authenticate you on the RapidShare server. This is pretty much the same you would do with a graphical download manager. The difference now is that you do it on the command line.</p>
<p>Below you will find examples about how to perform these actions using both wget and curl.</p>
<p><strong>IMPORTANT</strong>: Please note that in order to use these command-line utilities or any other download managers with RapidShare, you will have to check the <strong>Direct Downloads option</strong> in your account&#8217;s <strong>options page</strong>.</p>
<h4>Save your RapidShare Premium Account Cookie</h4>
<p>Saving your RapidShare cookie is a procedure that needs to be done <strong>once</strong>.</p>
<p>The login page is located at:</p>
<pre class="codesnp">https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi</pre>
<p>The login form requires two fields: <strong>login</strong> and <strong>password</strong>. These are pretty self-explanatory.</p>
<p>In the following examples, the RapidShare username is shown as <strong>USERNAME</strong> and the password as <strong>PASSWORD</strong>.</p>
<h5>Using wget</h5>
<p>In order to save your cookie using wget, run the following:</p>
<pre class="console">
wget \
    --save-cookies ~/.cookies/rapidshare \
    --post-data "login=USERNAME&#038;password=PASSWORD" \
    -O - \
    https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi \
    > /dev/null
</pre>
<p><strong>&#8211;save-cookies</strong> : Saves the cookie to a file called <code>rapidshare</code> under the <code>~/.cookies</code> directory (let&#8217;s assume that you store your cookies there)<br />
<strong>&#8211;post-data</strong> : is the POST payload of the request. In other words it contains the data you would enter in the login form.<br />
<strong>-O -</strong> : downloads the HTML data to the standard output. Since the above command is run only in order to obtain the cookie, this option prints the HTML data to stdout (Standard Output) and then discards it by redirecting stdout to <code>/dev/null</code>. If you don&#8217;t do this, wget will save the HTML data in a file called <code>premiumzone.cgi</code> in the current directory. This is just the Rapidshare HTML page, which is absolutely not needed.</p>
<h5>Using curl</h5>
<p>In order to save your cookie using curl, run the following:</p>
<pre class="console">
curl \
    --cookie-jar ~/.cookies/rapidshare \
    --data "login=USERNAME&#038;password=PASSWORD" \
    https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi \
    > /dev/null
</pre>
<p><strong>&#8211;cookie-jar</strong> : Saves the cookie to a file called <code>rapidshare</code> under the <code>~/.cookies</code> directory (it has been assumed previously that cookies are stored there)<br />
<strong>&#8211;data</strong> : contains the data you would enter in the login form.<br />
Curl prints the downloaded page data to stdout by default. This is discarded by sending it to <code>/dev/null</code>.</p>
<h4>Download files using your RapidShare Premium Account Cookie</h4>
<p>Having saved your cookie, downloading files from RapidShare is as easy as telling wget/curl to load the cookie everytime you use them to download a file.</p>
<h5>Downloading with wget</h5>
<p>In order to download a file with wget, run the following:</p>
<pre class="console">
wget -c --load-cookies ~/.cookies/rapidshare &lt;URL&gt;
</pre>
<p><strong>-c </strong>: this is used in order to resume downloading of the file if it already exists in the current directory and is incomplete.<br />
<strong>&#8211;load-cookies</strong> : loads your cookie.</p>
<h5>Downloading with curl</h5>
<p>In the same manner, in order to download a file with curl, run the following:</p>
<pre class="console">
curl -L -O --cookie ~/.cookies/rapidshare &lt;URL&gt;
</pre>
<p><strong>-L</strong> : Follows all redirections until the final destination page is found. This switch is almost always required as curl won&#8217;t follow redirects by default (read about how to check the server <a href="http://www.g-loaded.eu/2006/10/06/check-server-http-headers-with-curl/">http headers</a> with curl).<br />
<strong>-O</strong> : By using this switch you instruct curl to save the downloaded data to a file in the current directory. The filename of the remote file is used. This switch is also required or else curl will print the data to stdout, which is something you won&#8217;t probably like.<br />
<strong>&#8211;cookie</strong> : loads your Rapidshare account&#8217;s cookie.</p>
<h4>Setting up a Download Server</h4>
<p>Although most users would be satisfied with the above, I wouldn&#8217;t be surprised if you would want to go a bit further and try to setup a little service for your downloading pleasure. Here is a very primitive implementation of such a service. All you will need is standard command line tools.</p>
<p>This primitive server consists of the following:</p>
<ol>
<li>A <a href="http://en.wikipedia.org/wiki/Named_pipe">named pipe</a>, called &#8220;<strong>dlbasket</strong>&#8220;. You will feed the server with URLs through this pipe. Another approach would be to use a listening TCP socket with <a href="http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/">NetCat</a>.</li>
<li>A script, which, among others, contains the main server loop. This loop reads one URL at a time from dlbasket and starts a wget/curl process in order to download the file. If dlbasket is empty, the server should just stay there waiting.</li>
</ol>
<p>So, in short, the service would be the following:</p>
<pre class="codesnp">
cat &lt;&gt; dlbasket | ( while ... done )
</pre>
<p>All credit for the &#8220;<strong>cat &lt;&gt; dlbasket |</strong>&#8221; magic goes to <strong><em>Zart</em></strong>, who kindly helped me out at the #fedora IRC channel.</p>
<p>So, let&#8217;s create that service. The following assume that a user named &#8220;<strong>downloader</strong>&#8221; exists in the system and the home directory is <code>/var/lib/downloader/</code>. Of course you can set this up as you like, but make sure you adjust the following commands and the script&#8217;s configuration options accordingly.</p>
<p>First, create the named pipe:</p>
<pre class="console">
mkfifo -m 0700 /var/lib/downloader/dlbasket
</pre>
<p>If it does not exist, create a <code>bin</code> directory in the user&#8217;s home:</p>
<pre class="console">
mkdir -p /var/lib/downloader/bin
</pre>
<p>Also, create a directory where the downloaded files will be saved:</p>
<pre class="console">
mkdir -p /var/lib/downloader/downloads
</pre>
<p>The following is a quick and dirty script I wrote which actually implements the service. Save it as <strong>rsgetd.sh</strong> inside the user&#8217;s <code>bin</code> directory:</p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#! /usr/bin/env bash  </span>
&nbsp;
<span style="color: #666666; font-style: italic;">#  rsgetd.sh - Download Service</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#  Version 0.3</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#  Copyright (C) 2007 George Notaras (http://www.g-loaded.eu/)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  This program is free software; you can redistribute it and/or modify</span>
<span style="color: #666666; font-style: italic;">#  it under the terms of the GNU General Public License version 2 as</span>
<span style="color: #666666; font-style: italic;">#  published by the Free Software Foundation.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#  This program is distributed in the hope that it will be useful,</span>
<span style="color: #666666; font-style: italic;">#  but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #666666; font-style: italic;">#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span style="color: #666666; font-style: italic;">#  GNU General Public License for more details.</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Special thanks to 'Zart' from the #fedora channel on FreeNode</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># v0.3 - Oct 31 2009:</span>
<span style="color: #666666; font-style: italic;"># - corrected error: &quot;./bin/rsgetd.sh: line 37: [: argument expected&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># CONFIG START </span>
<span style="color: #007800;">HOMEDIR</span>=<span style="color: #ff0000;">&quot;/var/lib/downloader&quot;</span>
<span style="color: #007800;">DLBASKET</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOMEDIR</span>/dlbasket&quot;</span>
<span style="color: #007800;">DLDIR</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOMEDIR</span>/downloads/&quot;</span>
<span style="color: #007800;">LOGFILE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOMEDIR</span>/.downloads_log&quot;</span>
<span style="color: #007800;">CACHEFILE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOMEDIR</span>/.downloads_cache&quot;</span>
<span style="color: #007800;">LIMIT</span>=<span style="color: #ff0000;">&quot;25k&quot;</span>
<span style="color: #007800;">WGETBIN</span>=<span style="color: #ff0000;">&quot;/usr/bin/wget&quot;</span>
<span style="color: #666666; font-style: italic;"># Rapidshare Login Cookie  </span>
<span style="color: #007800;">RSCOOKIE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOMEDIR</span>/cookies/.rapidshare&quot;</span>
<span style="color: #666666; font-style: italic;"># CONFIG END</span>
&nbsp;
<span style="color: #007800;">DATETIME</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`date '+%Y-%m-%d %H:%M:%S'`</span>&quot;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$DLBASKET</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>
        <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> url ; <span style="color: #000000; font-weight: bold;">do</span>
                <span style="color: #666666; font-style: italic;"># First, check the cache if the file has been already downloaded</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CACHEFILE</span>&quot;</span> <span style="color: #660033;">-a</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(grep -i $(basename $url)</span> <span style="color: #007800;">$CACHEFILE</span>)&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
                       <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DATETIME</span> File exists in cache. Already downloaded - Skipping: <span style="color: #007800;">$url</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span>
                <span style="color: #000000; font-weight: bold;">else</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DATETIME</span> Starting with rate <span style="color: #007800;">$LIMIT</span>/s: <span style="color: #007800;">$url</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span>
                        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">expr</span> match <span style="color: #ff0000;">&quot;<span style="color: #007800;">$url</span>&quot;</span> <span style="color: #ff0000;">'[rapidshare.com]'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> = <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
                                <span style="color: #666666; font-style: italic;"># If it is a Rapidshare.com link, load the RS cookie </span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;RAPIDSHARE LINK&quot;</span>
                                <span style="color: #007800;">$WGETBIN</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">--limit-rate</span>=<span style="color: #007800;">$LIMIT</span> <span style="color: #660033;">--directory-prefix</span>=<span style="color: #007800;">$DLDIR</span> <span style="color: #660033;">--load-cookies</span> <span style="color: #007800;">$RSCOOKIE</span> <span style="color: #007800;">$url</span>
                        <span style="color: #000000; font-weight: bold;">else</span>
                                <span style="color: #007800;">$WGETBIN</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">--limit-rate</span>=<span style="color: #007800;">$LIMIT</span> <span style="color: #660033;">--directory-prefix</span>=<span style="color: #007800;">$DLDIR</span> <span style="color: #007800;">$url</span>
                        <span style="color: #000000; font-weight: bold;">fi</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DATETIME</span> Finished: <span style="color: #007800;">$url</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$url</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$CACHEFILE</span>
                <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">done</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>
<p>As you might have already noticed, two extra files are created inside the home directory: <code>.downloads_cache</code> and <code>.downloads_log</code>. The first contains a list of all the urls that have been downloaded. Each new download is checked against this list, so that the particular URL is not processed if the file has already been downloaded. The latter file is a usual logfile stating the start and end times of each download. Feel free to adjust the script to your needs.</p>
<p>Here is some info about how you should start the service:</p>
<p><strong>-1-</strong> You can simply start the script as a background process and then feed URLs to it. For example:</p>
<pre class="console">
rsgetd.sh &#038;
echo "&lt;URL&gt;" &gt; /var/lib/downloader/dlbasket
</pre>
<p><strong>-2-</strong> Use <a href="http://www.gnu.org/software/screen/">screen</a> in order to run the script in the background but still be able to see its output by connecting to a screen session. Although this is not a screen howto, here is an example:</p>
<p>Create a new screen session and attach to it:</p>
<pre class="console">
screen -S rs_downloads
</pre>
<p>While being in the session, run rsgetd.sh</p>
<pre class="console">
rsgetd.sh
</pre>
<p>From another terminal feed the download basket (dlbasket) with urls:</p>
<pre class="console">
echo "&lt;URL&gt;" &gt; /var/lib/downloader/dlbasket
cat url_list.txt &gt; /var/lib/downloader/dlbasket
</pre>
<p>Watch the files in the screen window as they are being downloaded.</p>
<p>Detach from the screen session by hitting the following:</p>
<pre class="codesnp">
Ctrl-a   d
</pre>
<p>Re-attach to the session by running:</p>
<pre class="console">
screen -r
</pre>
<p>Note that you do not need to be attached to the screen session in order to add URLs.</p>
<h5>Feeding the basket with URLs remotely</h5>
<p>Assuming that a SSH server is running on the machine that runs rsgetd.sh, you can feed URLs to it by running the following from a remote machine:</p>
<pre class="console">
ssh downloader@server.example.org cat \&gt; /var/lib/downloader/dlbasket
</pre>
<p>Note that the <strong>&gt;</strong> needs to be escaped so that it is considered as part of the command that will be executed on the remote server.</p>
<p>Now, feel free to <strong>add</strong> as many <strong>URLs</strong> as you like. After you hit the <strong>[Enter]</strong> key the url will be added to the download queue. When you are finished, just press <strong>Ctrl-D</strong> to end the URL submission.</p>
<h4>Conclusion</h4>
<p>This article provides all the information you need in order to use wget or curl to download files from your RapidShare Premium account. Also, information on how to set up a service that will assist you in order to commence downloads on your home server from a remote location has been covered.</p>
<p>The same information applies in all cases that wget and curl need to be used with websites that use cookie-based authentication.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/">Use wget or curl to download from RapidShare Premium</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2010/10/04/rsapiget-download-rapidshare-api/" rel="bookmark">rsapiget downloads files using the new Rapidshare API</a></li>
<li><a href="http://www.g-loaded.eu/2006/10/06/check-server-http-headers-with-curl/" rel="bookmark">Check Server HTTP Headers with CURL</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/mass-download/" rel="bookmark">Mass download</a></li>
<li><a href="http://www.g-loaded.eu/2006/01/06/partition-images-with-partimage-and-partimaged/" rel="bookmark">Partition images with Partimage and Partimaged</a></li>
<li><a href="http://www.g-loaded.eu/2010/03/28/script-apache-error-report/" rel="bookmark">Script for Apache Error Report</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>BIP IRC Proxy</title>
		<link>http://www.g-loaded.eu/2007/03/10/bip-irc-proxy/</link>
		<comments>http://www.g-loaded.eu/2007/03/10/bip-irc-proxy/#comments</comments>
		<pubDate>Sat, 10 Mar 2007 19:20:28 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Remote]]></category>
		<category><![CDATA[Servers]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/03/10/bip-irc-proxy/</guid>
		<description><![CDATA[A while back I had mentioned dircproxy as a solution for an IRC proxy server. Although dircproxy is good and effective, recently I&#8217;ve been reading many positive comments about another similar application, BIP. I hope I find some free time in the next days to give it a shot. Judging by its extensive feature set, [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I had <a href="http://www.g-loaded.eu/2007/02/01/dircproxy-irc-proxy/">mentioned</a> <a href="http://dircproxy.securiweb.net/">dircproxy</a> as a solution for an IRC proxy server. Although dircproxy is good and effective, recently I&#8217;ve been reading many positive comments about another similar application, <a href="http://bip.berlios.de/">BIP</a>. I hope I find some free time in the next days to give it a shot. Judging by its extensive feature set, chances are that I will like it, despite the fact that it is still marked as beta at the <a href="http://developer.berlios.de/projects/bip">BerliOS Project Page</a>.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/03/10/bip-irc-proxy/">BIP IRC Proxy</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2007/02/01/dircproxy-irc-proxy/" rel="bookmark">dircproxy IRC Proxy</a></li>
<li><a href="http://www.g-loaded.eu/2007/02/24/creative-commons-v30-licenses-launched/" rel="bookmark">Creative Commons v3.0 Licenses Launched</a></li>
<li><a href="http://www.g-loaded.eu/2007/03/15/cc-configurator-plugin-version-10-is-out/" rel="bookmark">CC Configurator plugin version 1.0 is out!</a></li>
<li><a href="http://www.g-loaded.eu/2006/11/01/bot-allow-content-and-cc-configurator-plugin-updates/" rel="bookmark">Bot-Allow-Content and CC-Configurator plugin updates</a></li>
<li><a href="http://www.g-loaded.eu/2007/07/29/best-practices-of-software-licensing/" rel="bookmark">Best Practices of Software Licensing</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/03/10/bip-irc-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>dircproxy IRC Proxy</title>
		<link>http://www.g-loaded.eu/2007/02/01/dircproxy-irc-proxy/</link>
		<comments>http://www.g-loaded.eu/2007/02/01/dircproxy-irc-proxy/#comments</comments>
		<pubDate>Thu, 01 Feb 2007 11:20:23 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[IRC]]></category>
		<category><![CDATA[Logging]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Software]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/02/01/dircproxy-irc-proxy/</guid>
		<description><![CDATA[Yesterday, I wrote about my need to be always connected to an IRC channel in order to keep a log of the chat even when I don&#8217;t follow the conversation in real-time. Under the given circumstances and not taking into account the possibility to keep my desktop machine always on, so XChat can log everything, [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I <a href="http://www.g-loaded.eu/2007/01/31/python-irc-bot/">wrote</a> about my need to be always connected to an <abbr title="Internet Relay Chat">IRC</abbr> channel in order to keep a log of the chat even when I don&#8217;t follow the conversation in real-time. Under the given circumstances and not taking into account the possibility to keep my desktop machine always on, so <a href="http://www.xchat.org/">XChat</a> can log everything, the only way to accomplish this task seemed to be the use of an IRC bot. But&#8230;<br />
<span id="more-340"></span><br />
I was <a href="http://www.g-loaded.eu/2007/01/31/python-irc-bot/#comment-5839">told</a> that I might need to get some kind of special permission in order to use a bot on IRC Networks. I can very well understand why there might be rules about the usage of bots and, taking into account my basic knowledge of the IRC world, I started looking for a bot alternative, before even using a bot&#8230;</p>
<p>&#8230;and I run across <a href="http://dircproxy.securiweb.net/">dircproxy</a>, which seems to be exactly what I need. <strong>dircproxy</strong> is an <em>IRC Proxy Server</em>. When the IRC client, eg XChat, connects to the actual IRC server through dircproxy for the first time, dircproxy creates a <a href="http://dircproxy.securiweb.net/wiki/FrequentlyAskedQuestions#Whatareconfigurationclasses">connection class</a> for the proxied connection. Even if the user disconnects its IRC client, dircproxy will continue to log channel and private messages and other events. Whenever the IRC client reconnects through dircproxy and provides a pre-defined password, the previous session is resumed and the client may get all the logged messages. So, to sum it up, the advantages of using dircproxy are:</p>
<ol>
<li>Even if you disconnect the IRC client, no private or channel messages are lost.</li>
<li>You can connect through your IRC proxy with any client and from any workstation and see all the messages you have missed.</li>
</ol>
<p>Besides, being always connected to an IRC network involves some risks, so one might wonder if dircproxy works with anonymous networks like <strong>tor</strong>. As it is stated in the FAQ, it <a href="http://dircproxy.securiweb.net/wiki/HowtoConfigureServer#UsingtheTORAnonymousNetwork">works</a>.</p>
<p>Definitely, very interesting software!</p>
<p>So, the task I need this for (message logging) does not make dircproxy much different than an <strong>IRC bot</strong>. However, I hope that the use of dircproxy is completely transparent, so I will not have to ask for any special permissions in order to connect to the IRC network through it.</p>
<p>I have only read the information that is available on the dircproxy website. I have not actually tested the software yet. I&#8217;ll report back when I do.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/02/01/dircproxy-irc-proxy/">dircproxy IRC Proxy</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2007/03/10/bip-irc-proxy/" rel="bookmark">BIP IRC Proxy</a></li>
<li><a href="http://www.g-loaded.eu/2011/04/02/how-secure-is-the-tor-network-for-everyday-internet-browsing/" rel="bookmark">How secure is the TOR network for everyday internet browsing?</a></li>
<li><a href="http://www.g-loaded.eu/2007/07/28/send-a-text-file-as-sms-with-a-sony-ericsson-mobile/" rel="bookmark">Send a text file as SMS with a Sony-Ericsson mobile</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/ssh-with-keys/" rel="bookmark">Setup the SSH server to use keys for authentication</a></li>
<li><a href="http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/" rel="bookmark">Netcat &#8211; a couple of useful examples</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/02/01/dircproxy-irc-proxy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
	</channel>
</rss>

