As others said it is not illegal, like anon mailing, BUT it depends, I recommend you:
1.Do not scan government & Millitery networks. ( you will get into trubble! )
2. Do not scan for trojan ports, eg. 27373, 1243, ....