I have a software package which is hard-coded to open a connection to a certain local IP address. Unfortunately, the local network settings have changed, And I can't access the source code (long story).

Is there a way - like ssh tunneling - to redirect a certain ip address to another?

For example, my software would contact, which will be redirected to, a real address on another machine, in a transparent way.

Any Ideas?


A colleague of mine introduced me to iptables:

iptables -t nat -A OUTPUT -d -j DNAT --to-destination

Add a static route for the server IP to the server's real IP on the client. Add the server IP address as a subinterface on the server.

server# ifconfig eth0:1

client# route add -host gw

Add the server IP as a subinterface on the server. Add another IP in that network to the client machine as a subinterface.

This assumes they are currently on the same network.

server# ifconfig eth0:1

client# ifconfig eth0:1

I think that's the way to go:

sudo ip addr add dev eth0

That simply adds an IP address to eth0

  • in which machine? – Adam Matan Oct 6 '09 at 6:45
  • @Udi, good question: if one could assign the target machine that extra IP address (if not used elsewhere to start with) then I guess this would be the same as reverting back to the old local network settings, which I assume does not work for you. In other words: I don't think you can use this (unless you actually need to refer to localhost, which you don't). – Arjan Oct 6 '09 at 12:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.