There’s a difference depending on how you got the name- was it a choice or was it just following the tradition or law?
Choice:
I was given my surname by my parents. (Then explain how and why)
My parents gave me the last name of ‘Smith, that of my mother. She was an only child and my grandparents were insistent that the family name be passed on.
Tradition/law:
I have my parents’ last name, of course.
I got my surname from my parents. (It happened automatically - there wasn’t really any giving or receiving. ‘Inherit’ isn’t wrong but it’s not a precise word for a label.)