Linux: The hole trick to bypass firewall restriction
Have you ever wondered how P2P software like Skype directly exchanges data when both client desktop sitting behind a firewall that only permits outgoing traffic.
This article explains how Skype & Co. get round firewalls using the hole trick. From the article:
Peer-to-peer software applications are a network administrator's nightmare. In order to be able to exchange packets with their counterpart as directly as possible they use subtle tricks to punch holes in firewalls, which shouldn't actually be letting in packets from the outside world.
This is a good article and a good idea carried out by Skype. This is not exactly a new concept (just search for NAT2NAT using google and you will get more information about this hack). Author has doen good job explaining the whole concept in clear language.
How do I bypass Linux firewall restriction?
This article also covers DIY hole punching using standard hping2 and nc (netcat) tools under Linux. From the article:
Firstly start a UDP listener on UDP port 14141 on the local/1 console behind the firewall:
local/1# nc -u -l -p 14141
An external computer "remote" then attempts to contact it.
remote# echo "hello" | nc -p 53 -u local-fw 14141
However, as expected nothing is received on local/1 and, thanks to the firewall, nothing is returned to remote. Now on a second console, local/2, hping2, our universal tool for generating IP packets, punches a hole in the firewall:
local/2# hping2 -c 1 -2 -s 14141 -p 53 remote
As long as remote is behaving itself, it will send back a "port unreachable" response via ICMP - however this is of no consequence. On the second attempt
remote# echo "hello" | nc -p 53 -u local-fw 14141
The netcat listener on console local/1 then coughs up a "hello" - the UDP packet from outside has passed through the firewall and arrived at the computer behind it.
Right now there is no perfect solution exists, if you are using Linux based firewall to avoid abuse.
Read more at Know-how: The hole trick - How Skype & Co. get round firewalls
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in other helpful articles:
- Tutorial simple Linux firewall configuration using NetFilter / iptables
- Virtuozzo iptables firewall
- Linux Iptables block all network traffic
- Traceroute to Bypass the Firewall filters and Personal Firewalls policy for home user
- Linux Iptables block incoming access to selected or specific ip address
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!


Hey great find and thanks for pointing out article.
The only way to prevent this is to block UDP entirely using iptables since UDP is connectionless, a stateful iptables firewall will not able to block anything. This is a great hack, IMPO.
PS: I am reading your blog since last one year but this is first time I am writing a comment
Thanks for comment
i am windows vista 32 how can i try your trick
thanks in advance
umar,
This Linux specific tip.