I was just wondering what would be the best way to stop a VPS from being attacked, bandwidth would be a problem in this case so methods that reduce the amount of incoming attacks and stop sending outgoing data would be great. I've been looking for some open source linux projects that can auto detect on an assumption of an attacker however I can't seem to find any success. Just wanted a good idea of some solutions or methods of reducing or stopping a DDOS attack.
There are many OS-level solutions to protect against application- and transport-layer DoS attacks, like SYN cookies, Apache modules, etc. However, to protect against a full bandwidth flood, unfortunately there is little you can do, as it is a function of the pipe of your VPS provider.
One good solution (which will also help you with the other kinds of attacks at the same time) is to point your domain at a DDoS-protection provider like Cloudflare: https://www.cloudflare.com/
They can basically soak up attacks of almost any size. The key, however, is to make sure that no one can determine the real IP address of your server once the domain is behind Cloudflare.