Hi there,
I have a problem setting up port forwarding using DNAT. I know this topic has been covered in several other posts, and i think i have read all of them and tried fixing my problem. Fact is that it still does not work and therefore i would like to ask you if you have any ideas....
After running the following script i get the error "Could not open a connection to host on port 81" when i telnet on the port 81 of my server. (telnetting to 130.59.138.34:80 from my server works)
iptables script:
*************************
Code:
iptables -t nat -F
iptables -t filter -F
iptables -A PREROUTING -t nat -p tcp --dport 81 -j DNAT --to 130.59.138.34:80
iptables -A FORWARD -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
server facts
************
2.6.18-5-amd64 #1 SMP x86_64 GNU/Linux
iptables v1.3.6
interfaces: eth0 (single ip) and lo
output of iptables -t nat --list
********************************
Code:
> iptables -t nat --list
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- anywhere anywhere tcp dpt:81 to:130.59.138.34:80
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
output of iptables-save
***************************
Code:
> iptables-save
# Generated by iptables-save v1.3.6 on Tue Dec 18 09:53:24 2007
*filter
:INPUT ACCEPT [34924:16179522]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [35722:30366922]
-A FORWARD -j ACCEPT
COMMIT
# Completed on Tue Dec 18 09:53:24 2007
# Generated by iptables-save v1.3.6 on Tue Dec 18 09:53:24 2007
*nat
:PREROUTING ACCEPT [1654:97177]
:POSTROUTING ACCEPT [408:24444]
:OUTPUT ACCEPT [405:24300]
-A PREROUTING -p tcp -m tcp --dport 81 -j DNAT --to-destination 130.59.138.34:80
COMMIT
# Completed on Tue Dec 18 09:53:24 2007