Answer
A child is regarded as illegitimate if it is born without Nikah taking place or it is born less than 6 months after the Nikah of his/her parents.
In these cases, when the child is considered illegitimate, then it will not inherit or carry the name of the father. (Shaami vol.3 pg.540)
and Allah Ta’ala Knows Best
Mufti Ebrahim Desai