Trying to Port Forward with iptables to hardware router
by PROBLEMCHYLD from LinuxQuestions.org on (#5GE13)
I have tried forward chains prerouting and postrouting chains.
I don't want to open up port forwarding on my hardware router because the ports are always open. I want iptables to forward the necessary port 29000 to the hardware router when needed.
How do I allow this?
iptables -t nat -A PREROUTING -d Public IP -p tcp -m tcp --dport 29000 -j DNAT --to-destination 192.168.0.12:29000
iptables -t nat -A PREROUTING -d Public IP -p udp -m udp --dport 29000 -j DNAT --to-destination 192.168.0.12:29000
iptables -A FORWARD -d 192.168.0.12/32 -p tcp -m tcp --dport 29000 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -d 192.168.0.12/32 -p udp -m udp --dport 29000 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.12/32 -p tcp -m tcp --sport 29000 -j SNAT --to-source Public IP
iptables -t nat -A POSTROUTING -s 192.168.0.12/32 -p udp -m udp --sport 29000 -j SNAT --to-source Public IP


I don't want to open up port forwarding on my hardware router because the ports are always open. I want iptables to forward the necessary port 29000 to the hardware router when needed.
How do I allow this?
iptables -t nat -A PREROUTING -d Public IP -p tcp -m tcp --dport 29000 -j DNAT --to-destination 192.168.0.12:29000
iptables -t nat -A PREROUTING -d Public IP -p udp -m udp --dport 29000 -j DNAT --to-destination 192.168.0.12:29000
iptables -A FORWARD -d 192.168.0.12/32 -p tcp -m tcp --dport 29000 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -d 192.168.0.12/32 -p udp -m udp --dport 29000 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.12/32 -p tcp -m tcp --sport 29000 -j SNAT --to-source Public IP
iptables -t nat -A POSTROUTING -s 192.168.0.12/32 -p udp -m udp --sport 29000 -j SNAT --to-source Public IP