The United States needs to develop offensive weapons in cyberspace as part of its effort to protect the nation from cyber attacks, a senior military official said Thursday.

"If your defense is only to try to block attacks you can never be successful," General Keith Alexander, director of the National Security Agency and commander of the US Cyber Command, told a Washington symposium.

"At times, the government has to look at what you have to do to stop an attack -- stop it before it happens. Part of our defense has to consider offensive measures."

Alexander, who spoke at a cybersecurity summit sponsored by the US Chamber of Commerce, said any offensive cyber action would need to follow rules of engagement similar to those in other military situations.

"We have to have a discussion on this," he said.

Alexander's comments come as the US military has started studying various strategies in cyberspace, including offensive weapons.

The Defense Advanced Research Projects Agency has begun studying building a platform for offensive capabilities in cyberspace and has called for participation from academic and industry experts.

The US government has stopped short of confirming involvement in cyber weapons such as the Flame and Stuxnet viruses that have targeted Iran, but many analysts say there is evidence of US or Israeli involvement.