# Basic Iptables problem: iptables -L doesn't show my rules

## tscolari

I'm a noob in iptables, and I was trying to make a simple rule:

my eth0 port 8888 (for example) redirect to my localhost port 3306, so I can connect from outside to the mysql running locally.

I've started iptables (/etc/init.d/iptables start) and tryed to add, what seems to me, that rule:

```
iptables -t nat -I PREROUTING --source 0/0 --destination 0/0 -p tcp --dport 8888 -j REDIRECT --to-ports 3306

iptables -L

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination 
```

then I changed for -I to -A

```
iptables -t nat -A PREROUTING --source 0/0 --destination 0/0 -p tcp --dport 8888 -j REDIRECT --to-ports 3306

iptables -L

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination 
```

but, when I do a iptables-save my rule is printed in the output:

```
# Generated by iptables-save v1.4.10 on Fri Jan 21 21:55:41 2011

*security

:INPUT ACCEPT [1032:99461]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [831:528601]

COMMIT

# Completed on Fri Jan 21 21:55:41 2011

# Generated by iptables-save v1.4.10 on Fri Jan 21 21:55:41 2011

*raw

:PREROUTING ACCEPT [1031:99409]

:OUTPUT ACCEPT [831:528601]

COMMIT

# Completed on Fri Jan 21 21:55:41 2011

# Generated by iptables-save v1.4.10 on Fri Jan 21 21:55:41 2011

*nat

:PREROUTING ACCEPT [0:0]

:POSTROUTING ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A PREROUTING -p tcp -m tcp --dport 8888 -j REDIRECT --to-ports 3306 

COMMIT

# Completed on Fri Jan 21 21:55:41 2011

# Generated by iptables-save v1.4.10 on Fri Jan 21 21:55:41 2011

*mangle

:PREROUTING ACCEPT [1030:99357]

:INPUT ACCEPT [1030:99357]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [831:528601]

:POSTROUTING ACCEPT [831:528601]

COMMIT

# Completed on Fri Jan 21 21:55:41 2011

# Generated by iptables-save v1.4.10 on Fri Jan 21 21:55:41 2011

*filter

:INPUT ACCEPT [1030:99357]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [831:528601]

COMMIT

# Completed on Fri Jan 21 21:55:41 2011
```

But iptables -L still not showing it, and its definitely not redirecting to the 3306 port in the local interface.

Am I doing something wrong?

Or maybe, is the rule wrong? 

Any help? =p

----------

## Hu

Yes, you are doing it wrong.  You are adding a rule to the nat table, then listing the default table, which is filter.  If you want to see a non-default table, you must specify that table when listing, just as you must specify it when you add a rule to it.

----------

## d2_racing

Also, try :

```

iptables -L -t nat

```

----------

