mercoledì, luglio 08, 2015

Linux Debian/Ubuntu, default GATEWAY e DNS


ip command to set a default router to 192.168.1.254

Login as the root and type:
# ip route add default via 192.168.1.254
OR
$ sudo ip route add default via 192.168.1.254

route command to set a default router to 192.168.1.254

Login as the root and type:
# route add default gw 192.168.1.254
OR
$ sudo route add default gw 192.168.1.254

Save routing information to a configuration file /etc/network/interfaces

Open /etc/network/interfaces file
# vi /etc/network/interfaces
OR
$ sudo vi /etc/network/interfaces

Find eth0 or desired network interface and add following option
gateway 192.168.1.254

Save and close the file. Restart networking:
# /etc/init.d/networking restart
OR
$ sudo /etc/init.d/networking restart

Per i DNS, editare il file /etc/resolv.conf ed aggiungere:

nameserver 8.8.8.8
nameserver 8.8.4.4

domenica, aprile 12, 2015

Script in PHP per cancellazione di files

Ho trovato questo script in php molto utile per la cancellazione di intere directory e contenuti, cosa che molto spesso capita di fare e che molto spesso non ci si riesce a causa di crash continui o blocchi del client ftp di turno.

Indicare a fine listato la directory da rimuovere: remove('it/');
Script:
 <?php

function remove($dirname = '.')
{
        if (is_dir($dirname))
        {
                echo "$dirname is a directory.<br />";

                if ($handle = @opendir($dirname))
                {
                        while (($file = readdir($handle)) !== false)
                        {
                                if ($file != "." && $file != "..")
                                {
                                        echo "$file<br />";

                                        $fullpath = $dirname . '/' . $file;

                                        if (is_dir($fullpath))
                                        {
                                                remove($fullpath);
                                                @rmdir($fullpath);
                                        }
                                        else
                                        {
                                                @unlink($fullpath);
                                        }
                                }
                        }
                        closedir($handle);
                }
        }
}

remove('it/'); // Questa e' la directory che verrà svuotata.

?>

OpenVPN server - installazione su Windows 10

SERVER