Perl - Choose interface to connect through
- by Dieterve
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: $!";