Linux

Ruby and BitTorrent

As of today, we know what BitTorrent is and how to use it. The original implementation of BitTorrent has been written in Python by Bram Cohen. From the BitTorrent, Python is now one of well-known language wider. Thanks! The original implementation then has been modified and extended to support more sophisticate features and some of them are so popular right now, e.g., ABC and BitTornado. Then Java, C, C++, and C# have been used to implement in different ways, e.g., Azureus, libbt, BitComet, uTorrent, and etc. Where is Ruby?

Find old files using find, du and awk

My friend provides a shared disk space among trusted friends. Everybody are allowed to upload files to and download files from this space. The problem is that free space run out so fast. I have to help him identify oldest files to remove. If you are on *nix-based operating system, you might know about "find", "du" and "awk". To simplify this tip, I will demonstrate how to use find effectively.

  • You want to find files modified exactly 7 days ago.
    find . -ctime 7
  • You want to find files modified 7 days ago or older.
    find . -ctime +7

How to enable NAT in iptables

In my previous post regarding OpenVPN, I assumed that the machine is already running iptables as a gateway. If the machine is just a standalone server, you have to enable NAT gateway in iptables. In order to do that, modify /etc/sysconfig/iptables to follow below sample.

*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i tun+ -j ACCEPT
-A INPUT -i tap+ -j ACCEPT  

How to install OpenVPN on Fedora Core 2

Once you have a server and want to work like you sit in front of the console, you are looking for VPN. I have set many VPN on Linux servers. There are so many solutions and standards. Anyway, most of them rely on the standard and UDP protocol. UDP is good for tunneling but might not work correctly behide NAT and firewall. Usually, all networks allow to access web through web proxy. The web protocol, HTTP, relies on TCP protocol. OpenVPN is a VPN solution which supports both UDP and TCP at the same time. Cool! You can even establish VPN connection through HTTP proxy.

iptables: IP Packets's Flow

One picture is better than thousand words. If you don’t understand how iptables work in my previous post about secure Linux gateway, it is because you don’t know how it works and what the chains are. To understand iptables’s flow at a glance, I found a brief explanation at IP Masquerading (NAT) using iptables.

ipmasq-html2x

Setup secure Linux gateway using iptables

Nowadays, you might have a network of computers linked as an intranet and you want to let them read/reply e-mail. So you have to connect them to Internet by something. The key component is a router aka gateway. You might just buy an ADSL router  with RJ45 port. Anyway, in case of you have too many machines, ADSL router maybe unable to handle all requests successfully due to design limitation. For example, ZyXEL Prestige 650-R can only handle 1024 concurrent connections. If the router has 1024 concurrent connections, next connection will be dropped silently.