iptables forward rule
I have one ubuntu server with two interfaces eth0 and eth1.
eth0 = public ip(external ip...lets say 188.8.131.52)
eth1 = intranet network(192.168.1.1)
I would like to forward all incoming traffic on port 2222 on my eth0(meaning all outside traffic that comes to 184.108.40.206) to some ip in my intranet network:192.168.1.8 on port 80.
Current firewall settings look like:
:INPUT ACCEPT [554835:51201971]
:FORWARD DROP [15:720]
:OUTPUT ACCEPT [429106:42169996]
-A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i eth1 -o eth0 -j ACCEPT
-A FORWARD -j LOG
-A FORWARD -d 192.168.1.8 -p tcp -m tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT (i added the rule)
# Completed on xxx
# Generated by iptables-save v1.4.4 xxx
REROUTING ACCEPT [2185732:127429431]
:OUTPUT ACCEPT [22380:1772561]
OSTROUTING ACCEPT [1123:166347]
-A PREROUTING -i eth0 -p tcp -m tcp --dport 2222 -j DNAT --to-destination 192.168.1.8:80 (here i added the rule too)
-A POSTROUTING -o eth0 -j MASQUERADE
cat /proc/sys/net/ipv4/conf/eth0/forwarding returns 1
You can see my attempt with the two rules i added in PREROUTING and FORWARD chains(after some search on net) but i failed to resolve the problem.
I have to mention that i have not modify the previous settings due to the fact that i do not want to create any problems to the current settings(i do not own the server i just got a task to create this forward) and that the server has a router and dhcp server role.
Am i doing something wrong? Or is one of the other rules that are blocking the forward?