How to redirect requests?

Consider a program that communicates with a database server. The IP address is fixed in the program code (hard coding) and there is no access to the program source code. The IP address of the database server must be changed. What solution do you suggest for the application to communicate with the database server with the new IP address?

Thank you.

Use DNS instead of static (fixed) IP address.

this way DNS aliasing can even handle failover so you can distribute your application without changes to source code.

Otherwise setup a Virtual IP pool which could get messy.

1 Like

if the program runs on linux, iptables can used to perform a redirect (see ubuntu - How can I redirect outbound traffic to another ip using iptables - Unix & Linux Stack Exchange), if not you can perform destination NAT on a router the host computer(the one running the program) is behind .