Abdullah bin Abbas reported,

The Messenger of Allah ﷺ traveled during Ramadan and fasted until he reached Usfan. Then he called for a vessel of water and drank from it during the day so that the people could see him, and he continued not fasting until he arrived in Mecca.Ibn Abbas used to say, "The Messenger of Allah ﷺ both fasted and broke his fast while traveling, so whoever wishes may fast, and whoever wishes may break his fast."

Bukhari 4279

Sahih

حدثنا علي بن عبد الله حدثنا جرير عن منصور عن مجاهد عن طاوس

عن ابن عباس قال

سافر رسول الله ﷺ في رمضان فصام حتى بلغ عسفان ثم دعا بإناء من ماء فشرب نهارا ليريه الناس فأفطر حتى قدم مكة قال وكان ابن عباس يقول صام رسول الله ﷺ في السفر وأفطر فمن شاء صام ومن شاء أفطر

البخاري 4279صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Expeditions
Chapter
Conquest of Makkah in Ramadan
Numbering
Darussalam 4279
Bukhari 4279