In the context of maritime transportation, waterborne shipping has developed quickly and attracted significant attention. This paper aims to propose a ship path planning model based on optimal control to provide reference paths for ships, prioritizing navigational efficiency and safety considerations. Based on the optimal control, the ship path planning problem is transformed into a multi-objective optimization problem, taking into account the speed constraints of ships during navigation. Then, the cost function based on the multi-objective optimization is constructed. Dynamic programming and numerical simulation are utilized to solve the value function, which is inducted to generate reference paths for ships. In addition, a case study including 12 Origin-Destination (OD) pairs in the Port of Rotterdam is conducted to generate reference paths. The simulation results showed that the model is proven to have high applicability in generating reference paths of ships navigating within the confines of port waters. By enhancing navigational safety and efficiency, the model could be used to provide invaluable guidance to both the bridge team and pilotage work.