That's what wikipedia has to say about this idiom:
British English
It is claimed that in British naval slang this term refers to a child of questionable parentage conceived on the gun deck, hence 'son of a gun'. However, the term possibly predates this claimed origin, and Snopes.com lists it as being part of the English lexicon since at least 1708.1 It is sometimes claimed that the saying has its origin in the supposed practice of women travelling on board ship and giving birth on a sectioned off portion of the gun deck. For instance, Admiral William Henry Smyth wrote in his 1867 book, The Sailor's Word-Book:[2] Son of a gun, an epithet conveying contempt in a slight degree, and originally applied to boys born afloat, when women were permitted to accompany their husbands to sea; one admiral declared he literally was thus cradled, under the breast of a gun-carriage.
American English
In American folk idiom (American), this term has similar meaning to the British one, but was derived from military bureaucratic treatment of young enlisted men of uncertain familial background. If a recruit was unable to state his father's name, officers recorded "A. Gun".[citation needed]
An urban legend sometimes states that a story reported in the October 7, 1864 The American Medical Weekly about a woman impregnated by a bullet that went through a soldier's scrotum and into her abdomen was the origin of the term "son of a gun." The story about the woman was a joke written by Dr. Legrand G. Capers; some people who read the weekly failed to realize that the story was a joke and reported it as true.[3]
In some sense your Dad was right about its meaning.