开发者

Redirect requests for external IP's to a local IP

Greetings.

I am working on a project form my company. We have an application that was written by one of our old techs - he was fired for browsing pornography websites work. Unfortunately, he took the source code of our application with him开发者_C百科, and hard-coded the IP address of our external server 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.


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.


Assuming you have an iptables firewall somewhere on the route you can use DNAT:

iptables -t nat -A PREROUTING -d [old server] -j DNAT --to-destination [new server]

It doesn't matter where exactly you run this, so long as it sees packets addressed to [old server] and has a valid route to [new server], so that could be on the host running the application, any intermediate router, or your edge firewall.

Of course you could always just edit the address inside the binary itself....


In your firewall/router set up NAT for that public IP so that it routes to your new private ip.


You can't just add a route to the new sever like you mentioned, because at the first router hop the packet will be routed to the old server.

You might be able to point the route at the local host, add the old server as an IP address on a local interface, and write a proxy server to forward the requests to the old server.

The best option IMO is to figure out how to decompress the binary and hex edit it. Do you know what language it's written in? Or call your lawyer to get the source code back. =)


Use the hosts file to route all requests to external IP to a local IP: http://en.wikipedia.org/wiki/Hosts_(file)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜