Ian Fleming, the creator of James Bond, served with British Naval Intelligence during World War II, and his service influenced the character and his stories.
Fleming was recruited into the Royal Navy in 1939 by Rear Admiral John Godfrey, Head of Naval Intelligence. Fleming entered as a lieutenant and quickly promoted to lieutenant commander. Although initially tasked as Admiral Godfrey's assistant, Commander Fleming had greater ambitions. He is widely believed to be the author of the "Trout Memo" circulated by Godfrey that compared intelligence gathering to a fisherman casting for trout. In the memo, he independently came up the plan to use a corpse with false documents to deceive the Germans, originally conceived by another agent and later used in Operation Mincemeat.
Fleming did draw on those around him for other characters in the James Bond novels. Villains had a tendency to share a name with people Fleming disliked while other characters got their names from his friendly acquaintances. The character of M, James Bond's boss, was based on Fleming's boss Rear Admiral Godfrey. The inspiration for the single-letter moniker came from Maxwell Knight, the head of MI5, who was known to sign his memos with only his first initial, M. Also, the fictional antagonistic organization SMERSH, takes its name from a real Russian organization called SMERSH that was active from 1943-1946. In the fictional version, SMERSH was an acronym of Russian words meaning "Special Methods of Spy Detection" and was modeled after the KGB; the real SMERSH was a portmanteau in Russian meaning "Death to Spies" and was a counterintelligence organization on the Eastern Front during WWII.
Cover of a 1943 SMERSH Manual
Finally, the plots for many of the Bond novels came from real-world missions carried out by the Allies. "Moonraker" is based on the exploits of the 30 AU in Kiel, Germany, while "Thunderball" has loose connections to Fleming's canceled operation Ruthless. Fleming also ties in his fictional world to the historical one after the war and during the Cold War.
Fleming's novels became very popular during his life and have remained so long after his death in 1964. His work spawned one of the most successful movie franchises in history.