can security software like firewall that are installed on the main server protect all VPS running on the system or individual firewall needed for all VPS?
Yes and no. The hardware will need to have all of the normal ports open, whereas a VPS owner may only require certain ports be open. Also, some firewalls will not work well, behave consistently, with a VPS.
it depends what virtualization is in use and for example in freevps/virtuozzo/openvz what kernel (firewall) modules are loaded on the hardware-node (main server)