Kapisi/roles/WebServer/files/apps/25u/routing.php

66 lines
4.8 KiB
PHP
Raw Normal View History

2024-01-16 14:56:43 -06:00
<?php
echo '<html>
<head>
<title>25U Routing Practice</title>
</head>
<body>';
//Example picture
2024-01-16 16:34:30 -06:00
echo '<img src=/assets/25u/example_network2.png style="width:100%;height:auto;" />';
2024-01-16 14:56:43 -06:00
echo '<h3>IP Chart</h3>';
// RFC1918
$seed = rand(1,3);
switch($seed) {
case 1: $base="10.".rand(0,255) ; break;
case 2: $base="172.".rand(16,31) ; break;
case 3: $base="192.168" ; break;
}
// Random Class C
$thirdoctet=rand(0,255);
// Find three nonidentical nets
$netid1=rand(0,7);
$netid2=$netid1;
while ($netid2==$netid1) {
$netid2=rand(0,7);
}
$netid3=$netid1;
while ($netid1==$netid3 OR $netid2==$netid3) {
$netid3=rand(0,7);
}
// Format display
$displaynet1 = $base.'.'.$thirdoctet.'.'.($netid1*32).'/'.rand(27,29);
$displaynet2 = $base.'.'.$thirdoctet.'.'.($netid2*32).'/'.rand(27,29);
$displaynet3 = $base.'.'.$thirdoctet.'.'.($netid3*32).'/30';
// Render
echo '<table style="width:100%;"><tr><th style="width:150px;">Device</th><th style="width:150px;">Interface</th><th style="width:150px;">NetID</th><th style="width:150px;">IP Address</th></tr>';
echo '
<tr><th style="border: 1px solid;" colspan=4>Network 3</th style="border: 1px solid;"></tr>
<tr><td style="border:1px solid;">RTR1</td style="border:1px solid;"><td style="border:1px solid;">G0/1</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet3.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
<tr><td style="border:1px solid;">RTR2</td style="border:1px solid;"><td style="border:1px solid;">G0/1</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet3.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
<tr><th style="border: 1px solid;" colspan=4>Network 1</th style="border: 1px solid;"></tr>
<tr><td style="border:1px solid;">RTR1</td style="border:1px solid;"><td style="border:1px solid;">G0/0</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet1.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
<tr><td style="border:1px solid;">SW1</td style="border:1px solid;"><td style="border:1px solid;">VLAN 1</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet1.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
<tr><td style="border:1px solid;">PC1</td style="border:1px solid;"><td style="border:1px solid;">NIC</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet1.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
2024-01-16 16:34:30 -06:00
<tr><td style="border:1px solid;">WAP1</td style="border:1px solid;"><td style="border:1px solid;">NIC</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet1.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
<tr><td style="border:1px solid;">LTP1</td style="border:1px solid;"><td style="border:1px solid;">Wireless</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet1.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
<tr><td style="border:1px solid;">Printer 1</td style="border:1px solid;"><td style="border:1px solid;">Wireless</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet1.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
2024-01-16 14:56:43 -06:00
<tr><th style="border: 1px solid;" colspan=4>Network 2</th style="border: 1px solid;"></tr>
<tr><td style="border:1px solid;">RTR2</td style="border:1px solid;"><td style="border:1px solid;">G0/0</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet2.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
<tr><td style="border:1px solid;">SW2</td style="border:1px solid;"><td style="border:1px solid;">VLAN 1</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet2.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
<tr><td style="border:1px solid;">PC2</td style="border:1px solid;"><td style="border:1px solid;">NIC</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet2.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
2024-01-16 16:34:30 -06:00
<tr><td style="border:1px solid;">WAP2</td style="border:1px solid;"><td style="border:1px solid;">NIC</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet2.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
<tr><td style="border:1px solid;">LTP2</td style="border:1px solid;"><td style="border:1px solid;">Wireless</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet2.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
<tr><td style="border:1px solid;">Printer 2</td style="border:1px solid;"><td style="border:1px solid;">Wireless</td style="border:1px solid;"><td style="border:1px solid;">'.$displaynet2.'<td style="border:1px solid;">&nbsp;</td style="border:1px solid;"></tr>
2024-01-16 14:56:43 -06:00
';
echo '</table>';
echo '</body></html>';