freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] How to specify the local ip address to connect from
- From: Marten Lehmann <lehmann AT cnm.de>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] How to specify the local ip address to connect from
- Date: Thu, 18 Oct 2012 10:57:47 +0200
Hello,
I'm not much into the glibc socket API, but the perl module http://search.cpan.org/~gbarr/IO-1.25/lib/IO/Socket/INET.pm manages to exactly do this: Define the local IP (and even port) a connection is made from.
First it looks if the option LocalAddr is specified, otherwise it leaves the decision to the OS:
$laddr = defined $laddr ? inet_aton($laddr) : INADDR_ANY;
And then, before connect() is called, it binds to the interface:
if($lport || ($laddr ne INADDR_ANY) || exists $arg->{Listen}) {
$sock->bind($lport || 0, $laddr) or
return _error($sock, $!, "$!");
}
If someone knows the underlying socket API of the OS, he can surely adapt this to create a localaddr option or similar for FreeTDS.
Kind regards
Marten Lehmann
On 18.10.2012 07:36, James K. Lowden wrote:
On Thu, 18 Oct 2012 04:18:00 +0200
Marten Lehmann <lehmann AT cnm.de> wrote:
How can I set the local ip address / interface that FreeTDS connects
from to the remote database host?
There is no facility in FreeTDS to control which interface is used. I
cannot offhand think of any way to control that using the standard
socket interface i.e. connect(2). That sort of thing would be
governed by the routing tables within the machine hosting the FreeTDS
application.
If I may ask, what prompts you to introduce a firewall between your
webserver and your database server? Surely the database server is on
a network not accessible from the outside?
--jkl
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
-
[freetds] How to specify the local ip address to connect from,
Marten Lehmann, 10/17/2012
-
Re: [freetds] How to specify the local ip address to connect from,
James K. Lowden, 10/18/2012
-
Re: [freetds] How to specify the local ip address to connect from,
Marten Lehmann, 10/18/2012
- Re: [freetds] How to specify the local ip address to connect from, Frediano Ziglio, 10/18/2012
-
Re: [freetds] How to specify the local ip address to connect from,
Marten Lehmann, 10/18/2012
- <Possible follow-up(s)>
-
Re: [freetds] How to specify the local ip address to connect from,
Steven Peterson, 10/29/2012
-
Re: [freetds] How to specify the local ip address to connect from,
James K. Lowden, 10/29/2012
-
Re: [freetds] How to specify the local ip address to connect from,
Steven Peterson, 10/29/2012
-
Re: [freetds] How to specify the local ip address to connect from,
James K. Lowden, 10/29/2012
-
Re: [freetds] How to specify the local ip address to connect from,
Steven Peterson, 10/29/2012
-
Re: [freetds] How to specify the local ip address to connect from,
Peter Deacon, 10/29/2012
- Re: [freetds] How to specify the local ip address to connect from, Steven Peterson, 10/30/2012
- Re: [freetds] How to specify the local ip address to connect from, James K. Lowden, 10/30/2012
- Re: [freetds] How to specify the local ip address to connect from, Frediano Ziglio, 10/30/2012
-
Re: [freetds] How to specify the local ip address to connect from,
Peter Deacon, 10/29/2012
-
Re: [freetds] How to specify the local ip address to connect from,
Steven Peterson, 10/29/2012
-
Re: [freetds] How to specify the local ip address to connect from,
James K. Lowden, 10/29/2012
-
Re: [freetds] How to specify the local ip address to connect from,
Steven Peterson, 10/29/2012
-
Re: [freetds] How to specify the local ip address to connect from,
James K. Lowden, 10/29/2012
-
Re: [freetds] How to specify the local ip address to connect from,
James K. Lowden, 10/18/2012
Archive powered by MHonArc 2.6.24.