  We study the rectification of spin current in $XXZ$ chains segmented in two
parts, each with a different anisotropy parameter. Using exact diagonalization
and a matrix product states algorithm we find that a large rectification (of
the order of $10^4$) is attainable even using a short chain of $N=8$ spins,
when one half of the chain is gapless while the other has large enough
anisotropy. We present evidence of diffusive transport when the current is
driven in one direction and of a transition to an insulating behavior of the
system when driven in the opposite direction, leading to a perfect diode in the
thermodynamic limit. The above results are explained in terms of matching of
spectrum of magnon excitations between the two halves of the chain.
