Search code examples
network-programminghttp-redirectiphostipv4

Redirect requests for external IP's to a local IP


I am working on a project form my company. We have an application that we unfortunately lost the source code for, it has the IP address of our external server hard-coded into it. We have recently changed servers, and need to change where the application tries to access our database. I'd really prefer not to reinvent the wheel, and remake the application...

I tried using the route command, but no dice.

route -p [new server] mask 255.255.255.255 [old server] metric 50 if [interface]

I set up a temp webserver on port 80 of the new box, typed in the old IP address in a browser of a machine with the said route added to it's tables, and it still went to the old server.

Any help making the route command work, or plausible alternatives? Eg: software to redirect, router tricks...etc.

  • Note: We tried using a reverse name lookup on our private dns server, but that failed as well.

Solution

  • Since the IP address is hardcoded in the binary, you can probably grep for it. It's probably represented as four bytes. You can then replace it with the new IP address using a hex editor.