Perl - Choose interface to connect through

Posted by Dieterve on Stack Overflow See other posts from Stack Overflow or by Dieterve
Published on 2010-03-12T12:01:11Z Indexed on 2010/03/12 12:07 UTC
Read the original article Hit count: 144

Filed under:
|
|

I have 2 interfaces on my server, eth0 and eth0:0. Those are 2 different external ips and obviously 2 different reverse domains.

When i open a IO::Socket::INET Perl uses the eth0 interface by default. I would like to use the second interface (eth0:0) because this has a different ip and i dont want to use my main ip/domain.

I have absolutely no idea how to select which interface to connect through.

Code i use to open a socket:

my $sock = new IO::Socket::INET(PeerAddr    => $server,
                                PeerPort    => $serverPort,
                                Proto       => 'tcp') or
                             die "Can't connect to server: $!";

© Stack Overflow or respective owner

Related posts about perl

Related posts about socket