View Single Post
  #7   (View Single Post)  
Old 21st December 2008
dextro dextro is offline
Port Guard
 
Join Date: Dec 2008
Posts: 21
Default

Code:
<?php

function g($url, $opts = array())
{
    if ( !isset($opts['ua']) )
        $opts['ua'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, $opts['ua']);
    if ( isset($opts['bind']) )
        curl_setopt($ch, CURLOPT_INTERFACE, $opts['bind']);
    if ( !($cr = curl_exec($ch)) )
        printf("<p>g() failed: url={$url}; curl_errno()=%d; curl_eror()=%s;</p>", curl_errno($ch), curl_error($ch));
    curl_close($ch);
    return $cr;
}

echo '216.232.236.243 => ' . g('http://94.75.205.177/ip.php', array('bind' => '216.232.236.243')) . "\n";
echo '207.6.112.184 => ' . g('http://94.75.205.177/ip.php', array('bind' => '207.6.112.184')) . "\n";

echo 'nfe0 => ' . g('http://94.75.205.177/ip.php', array('bind' => 'nfe0')) . "\n";
echo 'ngeth0 => ' . g('http://94.75.205.177/ip.php', array('bind' => 'ngeth0')) . "\n";
?>
Wrote a script to bind to IP and interface

Code:
gateway# php w.php
216.232.236.243 => 216.232.236.243
207.6.112.184 => 216.232.236.243
nfe0 => 216.232.236.243
ngeth0 => 216.232.236.243
gateway#
The main IP is the only one making requests even when the virtual interface is used!
Reply With Quote