Boko Haram fighters attacked a military base and two surrounding villages near the flashpoint Nigerian city of Maiduguri, killing at least 20 people and wounding 84.