Someone said to the Messenger of Allah ﷺ, "Messenger of Allah, shall I fast while traveling?" He used to fast often.The Messenger of Allah ﷺ replied, "If you wish, fast, and if you wish, break your fast."
أخبرنا محمد بن سلمة قال أنبأنا ابن القاسم قال حدثني مالك عن هشام بن عروة عن أبيه عن عائشة قالت إن
لرسول الله ﷺ يا رسول الله أصوم في السفر وكان كثير الصيام فقال له رسول الله ﷺ إن شئت فصم وإن شئت فأفطر
Bukhari narrated it in the Book of Fasting, Chapter on Fasting While Traveling and Breaking the Fast, Hadith 1943, from the hadith of Malik through this route, and it is also in Kubra, Hadith 2614, and in Muwatta (the narration of Abdul-Rahman bin Qasim, Hadith 465). The hadith has another version in Muwatta, the narration of Yahya bin Yahya (1/295), where he narrated it from Hisham, from his father, from Hamza, through this route.