0% found this document useful (0 votes)
32 views

Howtochangeip Script

This PHP script allows a user to automatically change their WAN/Internet IP address from a computer connected to a Netgear WGR614v9 router. The script runs a procedure to disconnect and then reconnect to the router, mimicking the process of manually changing the IP address from the router's administration settings. To use it, the script needs to be uploaded to a computer running Apache/PHP that is connected to the router. It can then be accessed via a web browser to reset the IP address with one click.

Uploaded by

malakawj8105
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Howtochangeip Script

This PHP script allows a user to automatically change their WAN/Internet IP address from a computer connected to a Netgear WGR614v9 router. The script runs a procedure to disconnect and then reconnect to the router, mimicking the process of manually changing the IP address from the router's administration settings. To use it, the script needs to be uploaded to a computer running Apache/PHP that is connected to the router. It can then be accessed via a web browser to reset the IP address with one click.

Uploaded by

malakawj8105
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

How to Change IP Automatically of WAN/Internet Side with PHP Script

Developed this for my own use to avoid having to go into the router settings and click Disconnect - Connect to reset my IP.

This procedure may come in handy who need to renew IP of WAN because of banned from the site or other reasons

If you have XAMPP or just any form of Apache with PHP you can run this on a computer connected to your WGR614v9 in any
way (wired or wireless) run it through the browser and it will reset your IP address, just as if you entered the setup, went
into stats, clicked info, clicked disconnect, then connect.

Could bookmark it for even faster access.

To use look for admin:secret change this to your own username/password credentials into the router setup and just access
it from your browser (e.g. http://localhost/ip.php. )

----------code---------------

<?php

// Information //
// Change IP Address Script by Elad Nava
// Developed for Netgear WGR614v9
// http://eladnava.com

// Usage //
// Access from browser e.g. http://localhost/ip.php
// Must be run on a computer connected to WGR614v9
// Change $ip to gateway if necessary

function routerDoConnect( $post )


{
$ip = "192.168.1.1";
$path = "/st_pptp.cgi";

$cleanPost = array();

$headers = "POST {$path} HTTP/1.1\r\n";


$headers .= "Host: {$ip}\r\n";
$headers .= "User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.11) Gecko/
2009060214 Firefox/3.0.11\r\n";
$headers .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
$headers .= "Accept-Language: en-us,en;q=0.5\r\n";
$headers .= "Accept-Encoding: gzip,deflate\r\n";
$headers .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
$headers .= "Referer: http://192.168.1.1/RST_st_pptp.htm\r\n";
$headers .= "Authorization: Basic " . base64_encode( "admin:secret" ) . "\r\n";
$headers .= "Content-Type: application/x-www-form-urlencoded\r\n";

foreach ( $post as $k => $v )


{
if ( is_array( $v ) )
{
$v = implode( "", $v );
}

$k = urlencode( $k );
$v = stripslashes( $v );
$v = urlencode( $v );

$cleanPost[] = "{$k}={$v}";
}

$postHeader = implode( "&", $cleanPost ) . "\r\n";

$headers .= "Content-Length: " . ( strlen( $postHeader ) - 2 ). "\r\n\r\n";


$headers .= $postHeader;
//echo nl2br( $headers );die();

$open = fsockopen( $ip, 80, $errno, $errstr, 60 );

if ( ! $open )
{
echo( 'There was a problem connecting to the source.' );
die();
}

fputs( $open, $headers );


fgets( $open, 4096 );

fclose( $open );
}

echo "Disconnecting from ISP...";


routerDoConnect( array( 'disconnect' => "Disconnect" ) );
echo " Disconnected.<br />";

echo "Establishing new connection to ISP...";


routerDoConnect( array( 'connect' => " Connect " ) );
echo " Connected.<br /><br />Please allow 5 - 10 seconds for network to initiate.";

?>

You might also like