title: Curl IPv6 /48 Addresses PHP --interface
body: <p>I have the following function(in functions.php, for example purposes..):</p>
  
  <pre><code>function url_get_contents($url, $ip){
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_INTERFACE, $ip);
      curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
      $data = curl_exec($ch);
      curl_close($ch);
      return $data;
  }
  </code></pre>
  
  <p>I need to have this function mount to IPv6 addresses that are in a mounted /48 on my interface (sit1).</p>
  
  <p>The following is my /etc/sysconfig/network-scripts/ifcfg-sit1:</p>
  
  <pre><code>DEVICE=sit1
  BOOTPROTO=none
  ONBOOT=yes
  IPV6INIT=yes
  IPV6TUNNELIPV4=**.***.**.***
  IPV6TUNNELIPV4LOCAL=***.**.**.**
  IPV6ADDR=****:***:*:***::*/64
  IPV6ADDR_SECONDARIES="****:***:*:***::/48"
  IPV6_DEFAULTGW=****:***:*:***::*
  </code></pre>
  
  <p>Obviously in the above code, IP addresses have been starred out.</p>
  
  <p>However, in php:</p>
  
  <pre><code>&lt;?php
  require_once('functions.php');
  function randomString(){
  $length = 16;
  $chars = "0123456789abcdef";
  $str = "";    
  for($i = 0; $i &lt; $length; $i++){ $str .= $chars[mt_rand(0, strlen($chars) - 1)]; }
  $str = str_split($str, 4); $str = implode(":", $str);
  return $str;
  }
  $url="http://www.whatismyipv6.com";
  $ip="****:***:*:***::" . randomString();
  $res=url_get_contents($url, $ip);
  print($res);
  exit();
  ?&gt;
  </code></pre>
  
  <p>This doesn't seem to work (address cannot be bound to possibly??).</p>
  
  <p>Anyone know how I can get this to work?</p>
  
  <p>Thanks!</p>
  
  <p>** NOTE: THIS ALL WORKS IF I MANUALLY ADD THE IP WITH /128 IN ifcfg-sit1**</p>