Raspberry pi change IP via webpage

  Raspberry pi change IP via webpage

 Save this as ip.php and put inside /var/www

do not forget to change permissions for /etc/network/interfaces

chown root:www-data /etc/network/interfaces

chmod g+w /etc/network/interfaces



// configuration
$localIP = getHostByName(getHostName());
$url1 = 'http://'.$_SERVER['HTTP_HOST'];
$url2 = '/ip.php';
//echo '{$url1 . $url2'};
$url = $url1.$url2;
echo $url;
$file = '/etc/network/interfaces';

// check if form has been submitted
if (isset($_POST['text']))
    // save the text contents
    file_put_contents($file, $_POST['text']);

    // redirect to form again
    header(sprintf('Location: %s', $url));
    printf('<a href="%s">Moved</a>.', htmlspecialchars($url));

// read the textfile
$text = file_get_contents($file);

<!-- HTML form -->
<form action="" method="post">
<textarea rows="18" cols ="90" name="text"><?php echo htmlspecialchars($text) ?></textarea>
<input type="submit" />
<input type="reset" />


Popular posts from this blog

How to clean DB from old logs in Magento 1.x

Reduce (shrink) and resize raw disk at Proxmox

Apache 2.4 + mod_wsgi + Python 3.7 + Django installation on Centos 7.10