During WW1, the British Royal Navy became concerned that U-boats could enter its harbor at Scapa Flow. In addition to installing nets, mines and hydrophones, large loops of wire were installed on the channels that could be opened for navigation, encircling the entire channel, in order to detect vessels by induction.<p>There were no successful attacks in WW1, but perhaps they were less careful in WW2 (or submarine degaussing rendered the technique ineffective), as a U-boat torpedoed and sank the battleship HMS Royal Oak in the harbor, with great loss of life.<p>Update: It seems that Gunther Prien made his attack before the defenses were fully restored.