I'm running Ubuntu Server (natty) in as a gateway/firewall in front of a private network. I have successfully enabled IP forwarding and NAT so the machines behind the firewall can connect to Internet (followed the instructions from https://help.ubuntu.com/11.04/serverguide/C/firewall.html).
What I want now, is that a specific IP behind this firewall, whenever wants to connect to an external service to enforced to use only a specific port:
192.168.0.2 (application) -> 22.214.171.1246 (gateway, fictive ip) -> 126.96.36.1996 (service, fictive ip)
So whenever 192.168.0.2 wants to connect to 188.8.131.526 I want it t be enforced by router to use port 10002 (from port range 10002-12000). 184.108.40.2066 allows connections from gateway to ports 10002-12000.
Is there a way to create a custom chain and plug it into ufw, so that I will still be able to use ufw in the intended way and be able to dynamically update this chain whenever I add machines behind this firewall.