Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 1CDB9632ED7 for ; Thu, 3 Sep 2009 09:51:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 07563-07 for ; Thu, 3 Sep 2009 12:51:38 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f206.google.com (mail-bw0-f206.google.com [209.85.218.206]) by mail.postgresql.org (Postfix) with ESMTP id 703D9632B76 for ; Thu, 3 Sep 2009 09:51:38 -0300 (ADT) Received: by bwz2 with SMTP id 2so1459998bwz.19 for ; Thu, 03 Sep 2009 05:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:from:date:x-google-sender-auth:message-id:subject:to:cc :content-type; bh=3e5nOPVAECdgnMmVNeHhtEYVl1WzoMa7HGW8Z7tpTe8=; b=l5ULBotOKxFjqf/m92G5bsPmKhEebj0hssUXW++87GS3RBgubuEXex7GjgG0bUs3zS HLeGYygL/rk9j+JmUURLnMWzrwgH5LlZvoPMAhzFcimVBxMUmb7dTTNRD6GnCLRWFdd5 qZJQCrMga/WwjjTOpk80em8/fbDPzOQRqdGzQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; b=Val8wkSg1/NYMJag4QQE5IFC/uDyMryxkjW6IW6tIxcTNiR9xFgXIiZCEoFtGfc/Ih tHoOFm18lF8kLxre5kADDNfYUsQKl1JaolxGNjM+RQFNlgcIPA76uhYwSI38WzLNQidp /cTov63igpha/VUYdoLe3zBQ3CgT30TpPcHHM= MIME-Version: 1.0 Received: by 10.103.64.19 with SMTP id r19mr4148393muk.8.1251982296132; Thu, 03 Sep 2009 05:51:36 -0700 (PDT) In-Reply-To: <1251977488.8237.154.camel@happy.home.mcmillan.net.nz> References: <20090902202318.hp0bplmn4kkc48k0@zeus.netdynamics.gr> <1251977488.8237.154.camel@happy.home.mcmillan.net.nz> From: Greg Stark Date: Thu, 3 Sep 2009 13:51:16 +0100 X-Google-Sender-Auth: 25c84b49f3b7a179 Message-ID: <407d949e0909030551x4d5374bo4311583d80e67eb2@mail.gmail.com> Subject: Re: How to select the source ip address for a connection to the database server To: Andrew McMillan Cc: dimitris.sakellarios@telesuite.gr, pgsql-php@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/3 X-Sequence-Number: 4061 On Thu, Sep 3, 2009 at 12:31 PM, Andrew McMillan wrote: > Nope, unless you're root you're unlikely to be able to choose the source > address for your connection, and even then it would be tricky. I don't think you need to be root to select a source address. But that's not helpful since libpq doesn't support binding to a particular interface. That would be a useful feature and we should probably add it to the TODO. You should note that the source address isn't actually a very secure way to protect your connections since any other host on that network could spoof your address. It sounds like what you're looking for is to control the interface the packets are routed through. This is separate from the source address as packets are often routed through multiple hosts along their way. Routing rules are not something individual applications normally get involved in. If the connections are being routed through the wrong interface then you have a global problem, not just with the database and it requires system-wide configuration changes. -- greg http://mit.edu/~gsstark/resume.pdf