I am running an Ubuntu server having 255 IP addresses. I want to write down a PHP script that uses each IP to do a curl request. Is this possible ?
Depends on the nature of the networking as far as your server is concerned, and what it would be connecting to.
In most cases, you'll lose two addresses out of a full 256 octet - one for the network address (192.168.21.0) and one for the broadcast address (192.168.21.255). Remember that you'll also need a router in the same local subnet (192.168.21.1), so you're down to 253. (Assuming this is a CIDR/24 network).
Curl has a --interface option - you can use this to specify which IP your request is coming from; you may want to consider writing in this in perl or something not web-oriented - might make it a bit easier.
Here's hoping you're not stuffing ballot boxes.