Masturbation is and is not a sin. If you are horny and you are single and it is causing you to maybe have premaritual sex, then it is allowed. It is not allowed however many times a day, just because the feeling is great.
If you are married, you should just bang your wife. But if it comes down to you not getting any from your wife, then you can masturbate, again not going crazy with it.