<?php
function readInterfaces($was){
/*
# 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
*/
$fileArray = file("/etc/network/interfaces");
foreach($fileArray as $key => $val){
if(preg_match("/".$was."/",$val)){
$splitter = preg_split("/ /",trim($val));
return $splitter[1];
}
}
return false;
}
//Beispiel
readInterfaces('address');
readInterfaces('gateway');
?>