I'm running debian and I've got the following network configuration:
eth0 Link encap:Ethernet
inet addr:192.168.16.6 Bcast:192.168.16.255 Mask:255.255.255.0
inet6 addr: fe80::204:75ff:fe9b:50e5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:167010058 errors:0 dropped:0 overruns:1 frame:0
TX packets:286396455 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3019943786 (2.8 GiB) TX bytes:161811580 (154.3 MiB)
Interrupt:16 Base address:0x2c00
eth1 Link encap:Ethernet
inet6 addr: fe80::202:55ff:fe07:6d6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:276813626 errors:2444616 dropped:0 overruns:0 frame:0
TX packets:87946731 errors:0 dropped:0 overruns:0 carrier:0
collisions:2444616 txqueuelen:1000
RX bytes:1634441886 (1.5 GiB) TX bytes:2402441796 (2.2 GiB)
Interrupt:29
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3896208 errors:0 dropped:0 overruns:0 frame:0
TX packets:3896208 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:828004427 (789.6 MiB) TX bytes:828004427 (789.6 MiB)
ppp0 Link encap:Point-to-Point Protocol
inet addr:XXX.XXX.XXX P-t-P:XXX.XXX.XXX.XXX Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:3324045 errors:0 dropped:0 overruns:0 frame:0
TX packets:740415 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:301507344 (287.5 MiB) TX bytes:100747638 (96.0 MiB)
eth0 is for the local area network and eht1 is connected to a DSL modem. I wish to redirect all incoming traffic from internet (port 81) to a machine in my local area network (192.168.16.8:3000). I'm using ufw but I disabled it to work with a clean iptables. I'm planning to turn it on again after the configuration is done.
I tried this:
iptables -A PREROUTING -t nat -i eth1 -p tcp --dport 81 -j DNAT --to 192.168.16.8:3000
iptables -I FORWARD -p tcp --dport 81 -i eth1 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW --dport 81 -i eth1 -j ACCEPT
But did not work! Here is the full log incuding an iptables -L: http://pastebin.com/5vXZ7pQu Here is an iptables-save log: http://pastebin.com/KPSCxL0x
Im using: net.ipv4.ip_forward = 1
Thanks!