The dynamic traveling salesman problem (DTSP) is significant in logistics distribution in real-world applications in smart cities, but it is uncertain and difficult to solve. This paper proposes a scheme library-based ant colony optimization (ACO) with a two-optimization (2-opt) strategy to solve the DTSP efficiently. The work is novel and contributes to three aspects: problem model, optimization framework, and algorithm design. Firstly, in the problem model, traditional DTSP models often consider the change of travel distance between two nodes over time, while this paper focuses on a special DTSP model in that the node locations change dynamically over time. Secondly, in the optimization framework, the ACO algorithm is carried out in an offline optimization and online application framework to efficiently reuse the historical information to help fast respond to the dynamic environment. The framework of offline optimization and online application is proposed due to the fact that the environmental change in DTSP is caused by the change of node location, and therefore the new environment is somehow similar to certain previous environments. This way, in the offline optimization, the solutions for possible environmental changes are optimized in advance, and are stored in a mode scheme library. In the online application, when an environmental change is detected, the candidate solutions stored in the mode scheme library are reused via ACO to improve search efficiency and reduce computational complexity. Thirdly, in the algorithm design, the ACO cooperates with the 2-opt strategy to enhance search efficiency. To evaluate the performance of ACO with 2-opt, we design two challenging DTSP cases with up to 200 and 1379 nodes and compare them with other ACO and genetic algorithms. The experimental results show that ACO with 2-opt can solve the DTSPs effectively.