It is narrated from Khuzaymah bin Thabit (may Allah be pleased with him) that a man asked the Prophet (ﷺ) about having intercourse with women from behind, or about a man having intercourse with his wife in her anus (Imam Shafi’i, may Allah have mercy on him, was unsure about the wording). The Prophet (ﷺ) said: “It is permissible.” When the man turned back, the Prophet (ﷺ) called him or ordered that he be brought back, and asked him: “What did you say? In which of the two private parts? From behind in the front private part? If it is like that, then it is correct. Or from behind in the anus itself? If that is what is meant, then it is not permissible. Indeed, Allah does not shy away from the truth. Do not approach women in their anus.” Imam Shafi’i (may Allah have mercy on him) said: They asked, “What do you say about this chain of narration?” So I said: My uncle and Abdullah bin Ali bin al-Sa’ib are both trustworthy. And he said: Muhammad (may Allah have mercy on him) informed me about the hadith scholar Ansari, that he spoke well about him, and Khuzaymah is among those narrators whose trustworthiness no scholar doubts. Therefore, I do not consider intercourse with women in the anus to be permissible; rather, I prohibit it.
Hadith Referenceمسند الإمام الشافعي / كتاب عشرة النساء والإيلاء والخلع / 1198
Hadith Takhrijاخرجه البيهقي: 7 / 196 - وفى المعرفة السنن والآثار له (4220) وابن ماجة ، النكاح، باب النهي عن اتيان النساء في ادبارهن (1924) وصححه ابن الجارود (728) وابن حبان۔