2015-10-27 20:11

I’ve been asked a few time how Portquiz.net works.

It’s really simple. It’s just made of a few iptables rules. I’m using the iptables-persistent Debian package to make the rules persist a reboot.

Here is the content of /etc/iptables/rules.v4:


# Generated by iptables-save v1.4.14 on Sun Aug 25 12:43:34 2013
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -i lo -j RETURN
-A PREROUTING -p icmp -j RETURN
-A PREROUTING -m state --state RELATED,ESTABLISHED -j RETURN
-A PREROUTING -p tcp -m tcp --dport 22 -j RETURN
-A PREROUTING -p tcp -m tcp --dport 21 -j RETURN
-A PREROUTING -p tcp -m tcp --dport 25 -j RETURN
-A PREROUTING -p tcp -m tcp --dport 80 -j RETURN
-A PREROUTING -p tcp -m tcp --dport 443 -j RETURN
-A PREROUTING -p tcp -j DNAT --to-destination :80
COMMIT
# Completed on Sun Aug 25 12:43:34 2013
# Generated by iptables-save v1.4.14 on Sun Aug 25 12:43:34 2013
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 25 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -j DROP
COMMIT
# Completed on Sun Aug 25 12:43:34 2013

The filter table is classical: ACCEPT a few services, then DROP the rest.

Portquiz.net logic is in the nat table:

  • Forward connection on any port to port 80 (DNAT –to-destination :80)
  • Except for normal services (just RETURN for normal activity)
2015-10-27 20:11

2 Comments

  1. Funny, did you know we’re still using it at Smile ? :)

    So, it’s not a secret anymore !

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>