Go on craigslist and buy a used 1980-90s steel frame Specialized RockHopper or HardRock. (with rigid -no suspension- fork).
This meets the requirements of under 300$, 21speeds, and a very durable frame worth upgrading the components on over time.
Swap out the tires for slick narrow 26x1.25 urban tires, if you plan on going fast as opposed to in dirt.