# iptables module with port forwarding

**URL:** <https://forum.ansible.com/t/iptables-module-with-port-forwarding/22075>\
**Category:** Ansible Project\
**Created:** [July 21, 2016, 6:41am UTC](https://forum.ansible.com/t/iptables-module-with-port-forwarding/22075 "2016-07-21T06:41:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chun-Hung\_Huang](https://avatars.discourse-cdn.com/v4/letter/c/c89c15/32.png) [@Chun-Hung\_Huang](https://forum.ansible.com/u/Chun-Hung_Huang)\
**Post date:** [July 21, 2016, 6:41am UTC](https://forum.ansible.com/t/iptables-module-with-port-forwarding/22075/1 "2016-07-21T06:41:53Z")

</div>

Hi ALL

I want to use iptables module to manage port forwarding

----\> EXT\_IP:EXT\_PORT ----\> INT\_IP:INT:PORT

If user request EXT\_IP with port 8001, it will forward to INT\_IP ( 192.168.100.131 ) and port 22.

I use iptables module but fail

**#** ansible -m iptables -a ‘table=nat chain=PREROUTING protocol=tcp match=tcp destination\_port=8001 jump=REDIRECT to\_destination=192.168.100.131 to\_ports=22’ gateway --ask-pass

gateway | FAILED! =\> {

“changed”: false,

“cmd”: “/usr/sbin/iptables -t nat -A PREROUTING -p tcp -m tcp -j REDIRECT --to-destination 192.168.100.131 --destination-port 8001 --to-ports 22”,

“failed”: true,

“msg”: “iptables v1.4.21: unknown option "–to-destination"\nTry `iptables -h’ or ‘iptables --help’ for more information.”,

“rc”: 2,

“stderr”: “iptables v1.4.21: unknown option "–to-destination"\nTry `iptables -h’ or ‘iptables --help’ for more information.\n”,

“stdout”: “”,

“stdout\_lines”:

}

I already check [https://docs.ansible.com/ansible/iptables\_module.html](https://docs.ansible.com/ansible/iptables_module.html)

Pleas tell me which option I should use?

Thanks
