This paper introduces an analytically tractable and computationally efficient model for legged robot dynamics during locomotion on a dynamic rigid surface (DRS), along with an approximate analytical solution and a real-time walking pattern generator synthesized based on the model and solution. By relaxing the static-surface assumption, we extend the classical, time-invariant linear inverted pendulum (LIP) model for legged locomotion on a static surface to dynamic-surface locomotion, resulting in a time-varying LIP model termed as “DRS-LIP”. Sufficient and necessary stability conditions of the time-varying DRS-LIP model are obtained based on the Floquet theory. This model is also transformed into Mathieu’s equation to derive an approximate analytical solution that provides reasonable accuracy with a relatively low computational cost. Using the extended model and its solution, a walking pattern generator is developed to efficiently plan physically feasible trajectories for quadrupedal walking on a vertically oscillating surface. Finally, simulations and hardware experiments from a Laikago quadrupedal robot walking on a pitching treadmill (with a maximum vertical acceleration of 1 m/s2) confirm the accuracy and efficiency of the proposed analytical solution, as well as the efficiency, feasibility, and robustness of the pattern generator, under various surface motions and gait parameters.