Iptables working strangely

Posted by user109985 on Ask Ubuntu See other posts from Ask Ubuntu or by user109985
Published on 2012-11-22T18:22:17Z Indexed on 2012/11/22 23:10 UTC
Read the original article Hit count: 125

Filed under:
|
|

I have Ubuntu 12.04 x64 installed in my laptop.

I'm quite new to linux, and I wanted to specify certain rules for the iptables firewall.

This is the saved config of my iptables:


*mangle

:PREROUTING ACCEPT [0:0]

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

:POSTROUTING ACCEPT [0:0]

COMMIT


*nat

:PREROUTING ACCEPT [0:0]

:INPUT ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

:POSTROUTING ACCEPT [0:0]

-A PREROUTING -p tcp -m tcp --dport 3306 -j DNAT --to-destination 192.168.1.100:3306

-A PREROUTING -p tcp -m tcp --dport 11002 -j DNAT --to-destination 192.168.1.100:11002

-A PREROUTING -p tcp -m tcp --dport 13000 -j DNAT --to-destination 192.168.1.100:13000

-A PREROUTING -p tcp -m tcp --dport 13001 -j DNAT --to-destination 192.168.1.100:13001

-A PREROUTING -p tcp -m tcp --dport 13002 -j DNAT --to-destination 192.168.1.100:13002

-A PREROUTING -p tcp -m tcp --dport 13003 -j DNAT --to-destination 192.168.1.100:13003

-A PREROUTING -p tcp -m tcp --dport 13004 -j DNAT --to-destination 192.168.1.100:13004

-A PREROUTING -p tcp -m tcp --dport 13061 -j DNAT --to-destination 192.168.1.100:13061

-A PREROUTING -p tcp -m tcp --dport 13099 -j DNAT --to-destination 192.168.1.100:13099

-A POSTROUTING -j MASQUERADE

COMMIT


*filter

:INPUT DROP [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT


-A INPUT -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT
COMMIT

In theory, what it does is to drop all connections in all ports except for http, mysql and few other ports.

Moreover, it redirects all mysql and 13000-13004..etc port connections to a specific local ip in the same port, which is 192.168.1.100.

But what I find strange is that when my firewall is active, it blocks absolutely all the input connections, even those which must not block (http, mysql). In fact, I'm literally blocked and I can't establish any external connection.

What am I doing wrong?

PS: I tested the firewall without those redirections, and it still block all inputs, so I suppose it's not the problem.

© Ask Ubuntu or respective owner

Related posts about 12.04

Related posts about iptables