This paper aims to make the sales company achieve maximum profits. It presents a mathematical model, in which we analyze the natural gas pipeline system, consider many factors (compressor stations, the volatility of users' gas consumption, the ability of the end segment of pipe's storage) in transmission and use the end segment of pipeline to store gas. Then, we use nonlinear programing algorithm to solve the given example to illustrate the rationality and economic advantages of end segment storage. Finally, the results show that, compared with other storage methods, the proposed one could achieve better performance.