Calculate correct netmask

I've added a netmask cidr calculator function from here: http://www.linuxquestions.org/questions/programming-9/bash-cidr-calculator-646701/

Just tested this on Digital Ocean system and it works. The netmask is set correctly after the reboot and networking works.