Wardialing (aka. scanning or demon dialing) is the practice of dialing all the phone numbers in a range in order to find those that will answer with a modem.
The legality of wardialing varies from place to place.
Some phone companies have detection equipment to detect wardialing and lock out attackers. However, much of this equipment only reacts if the numbers are sequentially dialed -- so many programs can randomize the order in which they dial.
When hackers target companies, one of the first things they do is wardial the central office near the company. Companies rarely control the dial-in ports as strictly as the firewall, and machines with attached modems are sprinkled throughout the company on people's desktop computers and special-purpose computers that communicate with partners.