You can do this pretty easily using asterisk and then just point your VoIP clients to it's IP address
But....
Whatever you do, unless you're an expert with network security, don't leave it on its default port if you'll expose it to the internet.
You'll have that many bots trying to get in that it'll DDoS you within a few hours of setting it up. Even if you have it on a different port, you'll have lots of bots trying to get in.
If you ever see those "unlimited international calls" cards sold in third world countries for like $5-10, those are mostly hacked VoIP systems that have accounts or access to a phone line