In this study, the longitudinal vibration of rods with variable cross-sections is studied. For the analytical solution of the problem, a new analytical method based on a recently developed method on the Riccati differential equation is utilized. The governing equation is reduced to Hill's type second-order ordinary differential equation. The transformed equations can readily be solved analytically for various cases according to the method. Seven cases have been considered, and the frequency equations for each case have been obtained. According to the method developed, the problem is solved in the simplest way. By using the present method, the reader can readily decide whether the problem is solved analytically or numerically. The present method can solve the problem of longitudinal vibration of rods having cross-sections of arbitrary shape. Finally, the method is also applied to the longitudinal vibration of stepped rods. Mode shapes are plotted for special values.