Port scanning itself is generally legal, but the legality depends on the context and intent. Performing port scans on your own network or with explicit permission is typically permissible. However, scanning networks without authorization can violate laws related to unauthorized access and may result in legal consequences.