There is a theorem, which is proved for example in "A field guide to algebra" by Antoine Chambert-Loir (link on Springer).
Theorem 6.2.5 says, I highlight the important part:
Let $(A,D)$ be a differential ring and consider the ring $A[T]$ of polynomials in one variable $T$ with coefficients in $A$. For any $b \in A[T]$, there is a unique derivation $D_b$ of $A[T]$ with $D_b(T) = b$ such that the canonical ring morphism $A \to A[T]$ is a differential morphism $(A,D) \to (A[T], D_b)$.
The proof is a longer calculation (checking that such a map is a derivation), yet not difficult. The last part basically just says that this derivation on the polynomial ring coincides with the derivation $D$ on the coefficient ring.
Now, as you have already noted, for any derivation $D(X^2+1) = 2X \cdot D(X)$ must hold. The theorem says that you can choose any $g \in \mathbb{Z}[X]$ and get a unique derivation $D$ such that $D(X) = g$.
Thus: For every polynomial $f(X)$ in the ideal generated by $2X \in \mathbb{Z}[X]$, there exists a derivation $D$ such that $D(X^2+1) = f(X)$. (because as $f \in (2X)$, exists $b \in \mathbb Z [X]$ with $2X\cdot b = f$. Use Theorem with $D(X) = b$)