This paper focuses on precise oil distribution in pipe network of lubrication system through optimizing the diameter of all pipes. We combine computational fluid dynamics and optimization theory in this problem. A software platform integrating Isight, ProE, Gambit and Fluent has been developed to realize automatic optimization. Quasi-Newton algorithm has been chosen after investigation on the relationship between pipe diameter and oil flow-rate, and the influence of partial derivative step factor has been investigated. Finally, a pipe network of one inlet and six outlets has been studied to verify the effectiveness of the proposed method, and the relative error of oil allocation is less than five percent for each outlet.