I asked Anas b. Malik about the shortening of the prayer (while travelling). He said: When the Messenger of Allah ﷺ went out on a journey of three miles or three farsakh (the narrator Shu'bah doubted), he used to pray two rak'ahs.
أَنَسٌ كَانَ رَسُولُ اللَّهِ ﷺ إِذَا خَرَجَ مَسِيرَةَ ثَلاَثَةِ أَمْيَالٍ أَوْ ثَلاَثَةِ فَرَاسِخَ شُعْبَةُ شَكَّ يُصَلِّي رَكْعَتَيْنِ