Network Interfaces

$current_interface, 'ip' => '', 'mac' => '', 'status' => 'down' ]; } // Extract IP address if ($current_interface && preg_match('/inet\s+(\d+\.\d+\.\d+\.\d+)/', $line, $matches)) { $interface_data[$current_interface]['ip'] = $matches[1]; } // Extract MAC address if ($current_interface && preg_match('/link\/ether\s+([a-f0-9:]+)/', $line, $matches)) { $interface_data[$current_interface]['mac'] = $matches[1]; } // Check if interface is up if ($current_interface && strpos($line, 'state UP') !== false) { $interface_data[$current_interface]['status'] = 'up'; } } // Display the filtered interfaces foreach ($interface_data as $interface) { if (!empty($interface['ip']) || !empty($interface['mac'])) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } } ?>
Interface Name IP Address MAC Address Status
" . htmlspecialchars($interface['name']) . "" . htmlspecialchars($interface['ip']) . "" . htmlspecialchars($interface['mac']) . "" . htmlspecialchars($interface['status']) . "