Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

4 Answers

up vote 3 down vote accepted

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
share|improve this answer
add comment

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
share|improve this answer
add comment

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
share|improve this answer
add comment

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

share|improve this answer
    
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
add comment

protected by Daniel Beck Aug 10 '12 at 17:48

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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