We derive equations of motion that describe the dynamics of a fluid confined within an elastic nanotube subject to periodic bending deflections. We use the principle of least action applied to a continuous open system at constant temperature. We solve the equations analytically in two limiting situations: when the tube oscillations are so small that they do not affect the fluid motion, but this one affects the tube dynamics; and when the flow magnitude is so small that it has no influence on the tube dynamics, but this one affects fluid motion. In the first case, we find out that the characteristic bending frequency spectrum of the tube depends not only on the magnitude of flow velocity, as previously stated in the literature, but also on the fluid velocity profile. This could constitute the basis of a strategy for indirect determination of the slip length in carbon nanotubes conveying flow via measurement of the buckling speed. In the second case, we find that tube vibrations can modify the dynamics of the fluid. Particularly, for a fluid subject to a constant pressure gradient, the tube motion induces an oscillatory motion in the fluid with twice the frequency of the tube. Moreover, the amplitude of the oscillatory fluid motion persists at high frequencies. This could constitute a strategy to generate high-frequency flows at nanoscales. Our results open up a panorama to control flow across nanotubes via tube vibrations, which could be complementary to chemical functionalization of nanostructures.