I have a service running on 127.0.0.1 with port 2222. I need to forward all requests to 192.168.2.2:2222 (outside IP) only from subnet 192.168.1.0/24 to 127.0.0.1:2222.I'm trying to use this, but it's not working.$ iptables -t nat -I PREROUTING -p tcp -d 192.168.1.0/24 --dport 2222 -j DNAT --to-destination 127.0.0.1:2222How can I get this to work?UPD: Edit address scheme. 
iptables redirect outside requests to 127.0.0.1
iptables;port forwarding;network interface
The iptables rule you are using will work, but there is one additional change you need to make:sysctl -w net.ipv4.conf.eth0.route_localnet=1(replacing eth0 with the nic 192.168.2.2 resides on)By default this value is 0, which instructs the kernel to not route external traffic destined to 127.0.0.0/8. This is just for security as such traffic is not normal.Additional note: your current iptables rule is too broad. Your rule specifies -d 192.168.1.0/24 --dport 2222 as the destination match, meaning that if your machine tries to talk to another host on port 2222 (i.e. outbound traffic), it'll get redirected as well. You either need to change the -d match to -d 192.168.2.2, or add -i eth0 (or whatever your nic is).