2

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 192.168.1.100, which will be redirected to 192.168.1.15, a real address on another machine, in a transparent way.

Any Ideas?

4

A colleague of mine introduced me to iptables:

iptables -t nat -A OUTPUT -d 192.168.1.100 -j DNAT --to-destination 192.168.1.15
1

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 192.168.1.100

client# route add -host 192.168.1.100 gw 192.168.1.15
0

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 192.168.1.100

client# ifconfig eth0:1 192.168.1.101
0

I think that's the way to go:

sudo ip addr add 192.168.1.100 dev eth0

That simply adds an IP address to eth0

2
  • 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 192.168.1.100 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.