Re: How to specify the local ip address to connect from

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CAHt6W4ecW93Egadb=7Bp3VsiYUTuzm+MOgNYghj2pjHnN5p0RA@mail.gmail.com>
Probably you can strace your program but should be a call to bind

Frediano


2012/10/18 Marten Lehmann <[email protected]>:
> 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 <[email protected]> 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?
>>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.