Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 5DD2563355F for ; Sat, 5 Sep 2009 21:58:19 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 08904-04 for ; Sun, 6 Sep 2009 00:58:00 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from emerald.lightlink.com (emerald.lightlink.com [64.57.176.19]) by mail.postgresql.org (Postfix) with ESMTP id 6A5CC632F5F for ; Sat, 5 Sep 2009 21:58:08 -0300 (ADT) Received: from [172.16.10.72] (cpe-24-58-18-216.twcny.res.rr.com [24.58.18.216]) by emerald.lightlink.com (8.9.3p2/8.8.8) with ESMTP id UAA23261; Sat, 5 Sep 2009 20:57:57 -0400 Message-ID: <4AA30914.7080102@lightlink.com> Date: Sat, 05 Sep 2009 20:57:56 -0400 From: Bob McConnell User-Agent: Thunderbird 2.0.0.23 (X11/20090812) MIME-Version: 1.0 To: dimitris.sakellarios@telesuite.gr CC: pgsql-php@postgresql.org Subject: Re: How to select the source ip address for a connection to the database server References: <20090902202318.hp0bplmn4kkc48k0@zeus.netdynamics.gr> In-Reply-To: <20090902202318.hp0bplmn4kkc48k0@zeus.netdynamics.gr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.392 tagged_above=-10 required=5 tests=AWL=1.207, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/6 X-Sequence-Number: 4064 dimitris.sakellarios@telesuite.gr wrote: > > I am currently working with PHP5+PGSQL 8.2.13 and i have the following > problem to solve and i need your help. > > The server hosting PHP+psql client has 1 physical network interfaces > with multiple subinterfaces using different IPs. > > One of those IP is dedicated to my domain, but it is not servers > default IP address since i share the server. > > So the problem that i need to solve is how am i going to be able to > use-select my domains IP address as source to connect to the remote > databases. > > Is there any configuration to settle default source IP the client will > use? > > At the moment all my attempts to connect to the database make use > of servers default interface IP as source. > > Thanks in advance for your help. That is the way sockets normally work, the primary address is always used for outgoing connections. It can not be changed without some low level programming. It is necessary to bind the socket to the specific IP address before opening the connection. I have done it with Perl, but not PHP. Bob McConnell N2SPP