Matt Mossholder on 17 Feb 2012 06:21:09 -0800 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] network choice from the application level |
On Thu, Feb 16, 2012 at 10:09 PM, Eric at Lucii.org <eric@lucii.org> wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Suppose: > > 1. I have two applications running on an OpenSuse server. > 2. This OpenSuse server has one NIC and two IP addresses. > 3. There is a database server in the same network > Â that has a *single* IP address. > > Is it possible for the applications (PHP) to select which of the two > OUTGOING IP addresses it uses to talk to the database server? > > The database people want the requests to come FROM a different IP > address depending on the particular application. > > I think it's impossible. > I told them to get another IP address for their database server and > then I can do it :-) > > Anybody know if it's possible? > > Eric A quick Google suggests that PHP always uses the IP that has the shortest path to the destination when sending packets, so you are going to have to do something "outside the box". A few things come to mind, in order of preference based on my impression of load: 1) There might be some things you could do with cgroups and/or Linux Containers (LXC) to mask out the IP addresses from the apps so that the only ones available are the ones you would like them to use, 2) iptables and NAT can be of use, as Doug suggests, 3) run a local reverse proxy (or even something like ncat), bound to localhost on a port for each app, and then have it establish the connections using the correct IPs for sources. --Matt ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug