in reply to raw sockets

You can use Net::Interface to get the IP address associated with "eth0", such as:
use Socket qw(AF_INET pack_sockaddr_in); use Net::Interface; my $intf = Net::Interface->new('eth0'); my $ipaddr = $intf->address(AF_INET);
and then bind() the socket to the local address as:
bind(SOCKET, pack_sockaddr_in(0, $ipaddr)) || die "can't bind socket t +o local address";
and this should achieve what you're asking to be able to do.