WriteInterfaces
Aus Programmers Guide
(Unterschied zwischen Versionen)
Roy (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „= Die /etc/network/interfaces mit PHP schreiben = <source lang="php"> <?php function writeInterfaces($ip,$gw,$dns){ /** # This file describes the network interf…“) |
Roy (Diskussion | Beiträge) |
||
Zeile 52: | Zeile 52: | ||
</source> | </source> | ||
- | [[Category:PHP]][[Category:Snippet]] | + | |
+ | |||
+ | [[ReadInterfaces]] | ||
+ | |||
+ | [[Category:PHP]] [[Category:Snippet]] |
Aktuelle Version vom 17:50, 6. Sep. 2010
Die /etc/network/interfaces mit PHP schreiben
<?php function writeInterfaces($ip,$gw,$dns){ /** # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth1 iface eth1 inet static address 192.168.1.245 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.253 dns-nameservers 192.168.1.253 dns-search elektrohauffe.intern */ $tmpSplit=preg_split("/\./",$ip); $subnet=$tmpSplit[0].".".$tmpSplit[1].".".$tmpSplit[2]; $inhalt=" auto lo iface lo inet loopback # The primary network interface auto eth1 iface eth1 inet static address $ip netmask 255.255.255.0 network $subnet.0 broadcast $subnet.255 gateway $gw dns-nameservers $gw dns-search $dns"; if(file_put_contents("/etc/network/interfaces",$inhalt)){ return true; } return false; } //Beispiel writeInterfaces('192.168.100.50','192.168.100.1','192.168.100.100'); ?>