Abu Hurairah reported,

While we were with the Messenger of Allah ﷺ, a man stood up and said, "Messenger of Allah, a black boy has been born to me."The Messenger of Allah ﷺ asked, "How could that be?"The man replied, "I do not know."The Prophet ﷺ asked, "Do you have any camels?"He said, "Yes."The Prophet ﷺ asked, "What are their colors?"He said, "Red."The Prophet ﷺ asked, "Is there a dusky one among them?"He said, "Yes, there are some dusky ones among them."The Prophet ﷺ asked, "How did that come about?"He said, "I do not know, Messenger of Allah, perhaps an ancestral strain produced it."The Prophet ﷺ said, "And this child of yours, perhaps an ancestral strain produced him."For this reason, the Messenger of Allah ﷺ ruled that it is not permissible for a man to disown a child born on his bed unless he claims to have witnessed an act of adultery.

Nasai 3510

Sahih

أخبرنا أحمد بن محمد بن المغيرة قال حدثنا أبو حيوة حمصي قال حدثنا شعيب بن أبي حمزة عن الزهري عن سعيد بن المسيب

عن أبي هريرة قال

بينما نحن عند رسول الله ﷺ قام رجل فقال يا رسول الله إني ولد لي غلام أسود فقال رسول الله ﷺ فأنى كان ذلك قال ما أدري قال فهل لك من إبل قال نعم قال فما ألوانها قال حمر قال فهل فيها جمل أورق قال فيها إبل ورق قال فأنى كان ذلك قال ما أدري يا رسول الله إلا أن يكون نزعه عرق قال وهذا لعله نزعه عرق فمن أجله قضى رسول الله ﷺ هذا لا يجوز لرجل أن ينتفي من ولد ولد على فراشه إلا أن يزعم أنه رأى فاحشة

النسائي 3510صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Divorce
Chapter
If he alludes to his wife and doubts his child and wants to disavow him
Numbering
Darussalam 3510
Nasai 3510