title: How to improve PHP IP generator function
body: <p>I am trying to generate random public IP addresses using PHP. I would appreciate feedback on the function I have made to do this as below. Is there any aspects you think can be improved in how it's coded? Can it be done in less lines of code? Are there reserved numbers which I've not catered for? Should I be using mt_rand() instead of rand()? All feedback appreciated. Thanks.</p>
  
  <pre><code>function generateIP() {
      $q1 = rand(3,253);
  
      //stop the first quadrant being one from a resrved range
      while ($q1 == '10'|| $q1 == '100'|| $q1 == '127' || $q1 == '169' || $q1 == '172' || $q1 == '192' || $q1 == '198' || $q1 == '203' || $q1 == '224' || $q1 == '240') {
          $q1 = rand(3,253);
      }
  
      $q2 = rand(0,255);
      $q3 = rand(0,255);
      $q4 = rand(0,255);
      $ip = $q1.'.'.$q2.'.'.$q3.'.'.$q4;
      return $ip;
  }
  </code></pre>