D/F#
First consider a basic D chord and the standard alternating bass line for this chord which alternates to the third string. Using the third string as a bass note restricts the right hand fingers to the second and first strings only (first position).
A way of overcoming this problem is to use an alternative fingering for the D chord such as the D/F# chord, meaning D chord with an F# bass note. Using this chord enables the right hand to use the sixth and fourth strings as bass notes thus allowing the right hand fingers to play the third and second strings. Study the D/F# chord diagram. Note that the F# bass note is played with the left hand thumb.