I have a doubt in understanding about the degrees of freedom (dof) ......as I have learned dof is nothing but the necessary parameters to specify the location and configuration of a system.....if that's so then why is there only two extra dof for diatomic molecules to account for the rotation of its molecules? The molecule can rotate about any axis which passes through the line joining the two atoms....when freely moving in space. So why we account dof as two only to uniquely specify it's configuration ? It should be greater than two
By analogy, think about the translational degrees of freedom. Even though there are only three axes of translation, the molecule can travel in any direction, because you can write its velocity vector as a linear combination of the unit vectors $ \vec u = a_x \hat u_x + a_y \hat u_y + a_z \hat u_z $. There is freedom in choosing what exactly these unit vectors are, but three are needed to express any velocity without degeneracy.
Likewise, you can write any angular velocity vector as the sum of the angular velocities about two axes, so there are only two degrees of freedom. (You only need two, rather than the three you'd expect for a 3-dimensional rotation, because the molecule is symmetric)
Well You choose degrees of freedom to tell the energy of a gas molecule alright. And the extra energy is provided by the rotation of the molecule.
We also know that energy of any rotating body is proportional to it's moment of inertia. The moment of inertia is of the form $I = kR^2$ that is it is proportional to the square of the distances between the mass and the axis of rotation.
Now for a diatomic molecule, the moment of inertia about the axis of the bond is very small (due to very small R). So we can approximate it to be zero.