Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <pre>
- /*******************************************
- * Author : Diego Cordoba / @d1cor *
- * Contact : d1cor.com.ar *
- *******************************************/
- </pre>
- <?php
- $target_ip=$_GET['ip'];
- $community=$_GET['c'];
- $result = snmprealwalk($target_ip,$community,'ipRoute');
- foreach($result as $indice => $valor){
- $variable=explode('::',$indice);
- $valor_e=explode(': ',$valor);
- $tmp1=explode('.',$variable[1]);
- $dir_ip="$tmp1[1].$tmp1[2].$tmp1[3].$tmp1[4]";
- if($tmp1[0]=='ipRouteIfIndex'){
- $ip_descr=snmpget($target_ip,$community,"ifDescr.$valor_e[1]");
- $ip_descr1=explode(': ',$ip_descr);
- $valor_e[1]=$ip_descr1[1];
- }
- if(($tmp1[0]=='ipRouteDest')&&($valor_e[1]=='0.0.0.0'))
- $valor_e[1]='default';
- $arreglo[$tmp1[0]][$dir_ip]=$valor_e[1];
- }
- echo "<h2>Routing table via snmp</h2>";
- echo "<table border=1>";
- echo "<tr><th>Destino</th>
- <th>Gateway</th>
- <th>Mascara</th>
- <th>Tipo</th>
- <th>Interfaz</th></tr>";
- foreach($arreglo['ipRouteDest'] as $indice => $valor ){
- echo "<tr><td>".$arreglo['ipRouteDest'][$indice]."</td>";
- echo "<td>".$arreglo['ipRouteNextHop'][$indice]."</td>";
- echo "<td>".$arreglo['ipRouteMask'][$indice]."</td>";
- echo "<td>".$arreglo['ipRouteType'][$indice]."</td>";
- echo "<td>".$arreglo['ipRouteIfIndex'][$indice]."</td></tr>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement