Witnesses say the bomber was a teenager.
Security forces quickly cordoned off the area. The naval installation suffered no damage because it was a safe distance from the gate, officials said.
Swat valley attack
The attack comes a day after a suicide bomber killed a provincial politician, detonating his explosives as he received guests at his home in Pakistan's northwest Swat valley.
More than a dozen people were wounded in that attack in Kanju town, police said.
Khan, 59, was a member of the Awami National Party, part of a coalition that rules the North West Frontier Province (NWFP).
The attacker struck as guests gathered to mark the end of the Muslim festival of Eid al-Adha, and the force of the blast damaged parts of the house and grounds.
Kanju town was the former headquarters of Mullah Fazlullah, the leader of the Pakistani Taliban.
Both attacks come during a Pakistani army offensive in Swat which began in April.