21. (12 points) As shown in the figure
3, given the endpoints of the major axis of the ellipse
$A$ and $B$, the chord $EF$ intersects $AB$ at
point $D$, $O$ is the center of the ellipse, and
$|OD|=1, 2DE$
$+DF=0, \angle FDO=\frac{\pi}{4}$
(1) Find the range of the length of the major axis of the ellipse;
(2) If $D$ is a focus of the ellipse, find the equation of the ellipse.
21. (1) Establish the rectangular coordinate system as shown in Figure 5, then $D(-1,0)$, and the equation of the line containing the chord $EF$ is
$$
y=x+1 .
$$

Let the equation of the ellipse be
$$
\begin{array}{c}
\frac{x^{2}}{a^{2}}+\frac{y^{2}}{b^{2}}=1 \\
(a>b>0), E\left(x_{1}, y_{1}\right), F\left(x_{2}, y_{2}\right) .
\end{array}
$$

From $2 D E+D F=0$, we know
$$
\begin{array}{l}
y_{1}+y_{2}=-y_{1}, y_{1} y_{2}=-2 y_{1}^{2} . \\
\text { By }\left\{\begin{array}{l}
\frac{x^{2}}{a^{2}}+\frac{y^{2}}{b^{2}}=1, \\
y=x+1,
\end{array} \text { eliminating } x\right. \text {, we get } \\
\left(a^{2}+b^{2}\right) y^{2}-2 b^{2} y+b^{2}-a^{2} b^{2}=0 .
\end{array}
$$

Then $\Delta=4 b^{4}-4\left(a^{2}+b^{2}\right)\left(b^{2}-a^{2} b^{2}\right)$
$$
=4 a^{2} b^{2}\left(a^{2}+b^{2}-1\right)>0 \text { (since } a^{2}+b^{2}>1 \text { ). }
$$

By Vieta's formulas, we know
$$
\begin{array}{l}
y_{1}+y_{2}=\frac{2 b^{2}}{a^{2}+b^{2}}=-y_{1}, \\
y_{1} y_{2}=\frac{b^{2}-a^{2} b^{2}}{a^{2}+b^{2}}=-2 y_{1}^{2} .
\end{array}
$$

Eliminating $y_{1}$, we get $\frac{b^{2}-a^{2} b^{2}}{a^{2}+b^{2}}=-2\left(\frac{2 b^{2}}{a^{2}+b^{2}}\right)^{2}$, i.e., $0<b^{2}=\frac{a^{2}\left(a^{2}-1\right)}{9-a^{2}}<a^{2}$.
Solving, we get $1<a^{2}<5$.
Thus, $2<2 a<2 \sqrt{5}$.
Therefore, the range of the length of the major axis of the ellipse is $(2,2 \sqrt{5})$.
(2) If $D$ is a focus of the ellipse, then $c=1$. Hence $b^{2}=a^{2}-1$.

We get $b^{2}=\frac{a^{2}\left(a^{2}-1\right)}{9-a^{2}}=a^{2}-1$.
Solving, we get $a^{2}=\frac{9}{2}, b^{2}=\frac{7}{2}$.
Therefore, the equation of the ellipse is $\frac{2 x^{2}}{9}+\frac{2 y^{2}}{7}=1$.