Howto redirect internet traffic from local machine back to local machine?

Martin Kahlert mkcon at
Mon Nov 28 08:55:25 CET 2005


Unfortunately i did not find a proper answer on the web although i googled
around for quite a lot of time:

I want to analyse a malware on my computer. The malware connects to a
lot of sites on the internet (hard coded in the program but unfortunately
these IPs are encrypted).

I know the port the program wants to connect to and i want to answer its
requests by a script on the same machine.

I tried this for a test to catch connections to mail servers:

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -F
iptables -t nat -A PREROUTING -p tcp -d ! --dport 25 -j DNAT

But it does not work:

$ telnet 25
Connected to         <--- of course, that's not my box
Escape character is '^]'.
220 {mp027} GMX Mailservices ESMTP

I assume the problem has something to do that the packets are generated
on the "iptables-machine". Unfortunately, i only have this machine and thus
i cannot send the packets through a second firewall-machine.

I would be very happy if any kind soul could give me a hint!

Thanks in advance,

More information about the netfilter mailing list