Defense is a little more complex than other settlement resources. To generate defense, the player can build a number of defensive improvements, ranging from fortifications, which require assigning a settler as guard, to autonomous turrets (small turrets run on their own power, while larger ones require separate power sources), as well as an assortment of traps. There is also a wandering salesman named Gene who sells junkyard dogs that provide 5 defense.
Defense directly affects the safety of a settlement. Low defense will invite raider attacks, which can – and will – wipe out entire towns. Note, however, that the game does not take settler equipment into account when calculating the defense rating. Equipping settlers with high end weapons and armor will provide protection while keeping the defense rating low will turn the town into a deathtrap – and provide a steady income of loot.