The toilets in our retirement home are six years old and some genius had taped over a couple of the holes under the rim (or just never removed them). We've tried everything including a brass bristle brush used for cleaning handguns. Zoom foam doesn't work, CLR doesn't work and I'm not enthusiastic about using sandpaper on the porcelain glazing. We are on a septic tank so very strong bleach is also out.
Empty the toilet of water or get it very low. Take some light weight cotton cloth or washcloth, and dip it in vinegar and ring it out. Stick it under the rim covering the stain. You will need about six cloths. You can cut washcloths in half. The cloths should stick to the porcelain. This also works for stains around the water line.
Let the cloths stay their for at least six hours. You can check to see if the stain is lessening. If the vinegar does not work, try dipping the cloths in CLR or any mineral remover, instead of the vinegar. Read the label on the product because some are very strong and can etch the coating off the porcelain. You would need to dilute it first.
Basically, the stains under the toilet rim are minerals that have stuck to the porcelain. They make a pretty tight bond so you need to dissolve them with acid to remove them. Rust removers are acidic. Vinegar is acetic acid.
You can also try lemon juice which is citric acid. For stains at the bottom of the bowl, empty all the water out of the toilet and pour in straight vinegar high enough to cover the stain. Then just let it sit until gone. Use a stronger acid as above if needed.
If you have hard crusted stains, the acid will loosen them but you may need to chip them away with a plastic spoon. You can also remove stains from under a faucet with the same cloth and acid technique.