Step 1: Use frequency relation for compass needle.
For a compass needle oscillating in earth's magnetic field, frequency is proportional to the square root of the horizontal component of magnetic field.
\[
n \propto \sqrt{B_H}
\]
Since,
\[
B_H = B\cos\theta
\]
we get
\[
n \propto \sqrt{B\cos\theta}
\]
Step 2: Write the ratio of frequencies.
Given,
\[
n_1=20,\quad n_2=30
\]
Dip angles are
\[
\theta_1=45^\circ,\quad \theta_2=30^\circ
\]
Therefore,
\[
\frac{n_1}{n_2}
=
\sqrt{\frac{B_1\cos45^\circ}{B_2\cos30^\circ}}
\]
Step 3: Substitute values.
\[
\frac{20}{30}
=
\sqrt{\frac{B_1\cos45^\circ}{B_2\cos30^\circ}}
\]
\[
\frac{2}{3}
=
\sqrt{\frac{B_1\cdot \frac{1}{\sqrt{2}}}{B_2\cdot \frac{\sqrt{3}}{2}}}
\]
Step 4: Square both sides.
\[
\left(\frac{2}{3}\right)^2
=
\frac{B_1}{B_2}\cdot \frac{\frac{1}{\sqrt{2}}}{\frac{\sqrt{3}}{2}}
\]
\[
\frac{4}{9}
=
\frac{B_1}{B_2}\cdot \frac{2}{\sqrt{6}}
\]
Step 5: Calculate \(B_1:B_2\).
\[
\frac{B_1}{B_2}
=
\frac{4}{9}\cdot \frac{\sqrt{6}}{2}
\]
\[
\frac{B_1}{B_2}
=
\frac{2\sqrt{6}}{9}
\]
Now,
\[
\frac{2\sqrt{2}}{3\sqrt{3}}
=
\frac{2\sqrt{2}\cdot \sqrt{3}}{3\sqrt{3}\cdot \sqrt{3}}
=
\frac{2\sqrt{6}}{9}
\]
Thus,
\[
B_1:B_2=2\sqrt{2}:3\sqrt{3}
\]
Step 6: Final conclusion.
Hence, the required ratio is
\[
\boxed{2\sqrt{2}:3\sqrt{3}}
\]