Save the following as /usr/lib/urxvt/perl/clipboard:
sub on_sel_grab {
my $query=quotemeta $_[0]->selection;
$query=~ s/\n/\\n/g;
$query=~ s/\r/\\r/g;
system( "echo -en " . $query . " | xsel -i -b -p" );
}
It also requires xsel and needs to be enabled in the *perl-ext-common or *perl-ext field in ~/.Xresources. For example:
URxvt.perl-ext-common: default,clipboard