INR Lab Practice - Week 2 | xml |
Algemeen
In Week 1 had ik al een begin gemaakt voor een eigen Python-script, voor de configuratie en generatie van compleet nieuwe UML-netwerkstructuren. Deze week heb ik dit script samen met Tjerk verder ontwikkeld. Het uiteindelijke script is hier te vinden. Het ontwikkelen van dit script was voor mij ook een goede oefening in Python, omdat ik voorheen vrijwel niet met Python heb gewerkt.
Starten van het UML-script
Om met het umlnet.py-script een nieuw UML-netwerk op te zetten, is een configuratiebestandje nodig waarin de betreffende netwerkconfiguraties staat opgeslagen. De inhoud van dit configuratiebestandje zal verderop in dit document worden besproken. Met het volgende commando kun je het netwerk starten:
./umlnet.py start configbestand.py
Op de plaats van "configbestand.py" dient uiteraard de naam van het betreffende configuratiebestand te worden ingevuld.
Stoppen van het UML-script
Om te zorgen dat alle UML-processen ook weer netjes worden gestopt, kan het volgende commando worden gebruikt:
./umlnet.py stop configbestand.py
Uiteraard dient ook hier het juiste configbestandje meegegeven te worden, omdat anders het verkeerde virtuele netwerk wordt gestopt.
Voorbeeldconfiguratie (H-network)
Als voorbeeld is hieronder de configuratie van het H-netwerk weergegeven. Dit voorbeeldscript is ook te downloaden: my-h-network.py
# Dit is een voorbeeld-configuratie, waarmee het H-netwerk kan worden gebouwd. networkName = 'H-Network' # De naam van je netwerk (maak dit uniek) numOfSubnets = 9 # Uit hoeveel subnetten het bestaat. # Samenstelling ethInfo (beschrijving posities in de array): # ========================================================== # Voor Host \ Router: Voor een Bridge: # - Naam ethernetkaart - Naam ethernetkaart # - (sub)Netwerknummer - (sub)Netwerknummer # - IP-adres - MAC-adres van de netwerkkaart # - Netwerkmasker # - Broadcastadres ethInfo1 = [['eth0', '1', '10.0.1.7', '255.255.255.0', '10.0.1.255']] # WS1 ethInfo2 = [['eth0', '4', '10.0.4.8', '255.255.255.0', '10.0.1.255']] # WS2 ethInfo3 = [['eth0', '5', '10.0.6.9', '255.255.255.0', '10.0.1.255']] # WS3 ethInfo4 = [['eth0', '8', '10.0.9.10', '255.255.255.0', '10.0.1.255']] # WS4 ethInfo5 = [['eth0', '1', '10.0.1.1', '255.255.255.0', '10.0.1.255'], # Router 1 ['eth1', '2', '10.0.2.1', '255.255.255.0', '10.0.1.255']] ethInfo6 = [['eth0', '2', '10.0.2.2', '255.255.255.0', '10.0.1.255'], # Router 2 ['eth1', '5', '10.0.5.2', '255.255.255.0', '10.0.1.255'], ['eth2', '3', '10.0.3.2', '255.255.255.0', '10.0.1.255']] ethInfo7 = [['eth0', '3', '10.0.3.3', '255.255.255.0', '10.0.1.255'], # Router 3 ['eth1', '4', '10.0.4.3', '255.255.255.0', '10.0.1.255']] ethInfo8 = [['eth0', '6', '10.0.6.4', '255.255.255.0', '10.0.1.255'], # Router 4 ['eth1', '7', '10.0.7.4', '255.255.255.0', '10.0.1.255']] ethInfo9 = [['eth0', '7', '10.0.7.5', '255.255.255.0', '10.0.1.255'], # Router 5 ['eth1', '5', '10.0.5.5', '255.255.255.0', '10.0.1.255'], ['eth2', '8', '10.0.8.5', '255.255.255.0', '10.0.1.255']] ethInfo10 = [['eth0', '8', '10.0.8.6', '255.255.255.0', '10.0.1.255'], # Router 6 ['eth1', '9', '10.0.9.6', '255.255.255.0', '10.0.1.255']] # Samenstelling networkSettings (beschrijving posities in de array): # ================================================================== # - Hostnaam # - systeemtype (bijv. router, generic of bridge) # - de gegevens van de ethernetkaart(en) zie ook ethInfo # - Default Gateway (kan ook leeg zijn: '') networkSettings = [['WS1', 'generic', ethInfo1, '10.0.1.1'], ['WS2', 'generic', ethInfo2, '10.0.4.3'], ['WS3', 'generic', ethInfo3, '10.0.6.4'], ['WS4', 'generic', ethInfo4, '10.0.9.6'], ['Router1', 'router', ethInfo5, ''], ['Router2', 'router', ethInfo6, ''], ['Router3', 'router', ethInfo7, ''], ['Router4', 'router', ethInfo8, ''], ['Router5', 'router', ethInfo9, ''], ['Router6', 'router', ethInfo10, '']]
Netwerktopologie - opdrachten
Hieronder staan de configuratiebestandjes vermeld, waarin de configuraties staan opgeslagen van de te maken netwerktopologien.
Opdracht 1
networkName = 'Opdracht1' numOfSubnets = 2 ethInfo1 = [['eth0', '1', '10.0.1.1', '255.255.255.0', '10.0.1.255']] # host1 ethInfo2 = [['eth0', '1', '00:30:48:28:01:01'], # bridge ['eth1', '2', '00:30:48:28:01:02']] ethInfo3 = [['eth0', '2', '10.0.1.3', '255.255.255.0', '10.0.1.255']] # host2 networkSettings = [['Host1', 'generic', ethInfo1, ''], ['Bridge', 'bridge', ethInfo2, ''], ['Host2', 'generic', ethInfo3, '']]
Opdracht 2
networkName = 'Opdracht2' numOfSubnets = 2 ethInfo1 = [['eth0', '1', '10.0.1.1', '255.255.255.0', '10.0.1.255']] # host1 ethInfo2 = [['eth0', '1', '00:30:48:28:01:01'], # bridge1 ['eth1', '2', '00:30:48:28:01:02']] ethInfo3 = [['eth0', '1', '00:30:48:28:02:01'], # bridge2 ['eth1', '2', '00:30:48:28:02:02']] ethInfo4 = [['eth0', '2', '10.0.1.2', '255.255.255.0', '10.0.1.255']] # host2 networkSettings = [['Host1', 'generic', ethInfo1, ''], ['Bridge1', 'bridge', ethInfo2, ''], ['Bridge2', 'bridge', ethInfo3, ''], ['Host2', 'generic', ethInfo4, '']]
Opdracht 3
networkName = 'Opdracht3' numOfSubnets = 2 ethInfo1 = [['eth0', '1', '10.0.1.1', '255.255.255.0', '10.0.1.255']] # host1 ethInfo2 = [['eth0', '1', '00:30:48:28:01:01'], # bridge1 ['eth1', '2', '00:30:48:28:01:02']] ethInfo3 = [['eth0', '1', '00:30:48:28:02:01'], # bridge2 ['eth1', '2', '00:30:48:28:02:02']] ethInfo4 = [['eth0', '1', '00:30:48:28:03:01'], # bridge3 ['eth1', '2', '00:30:48:28:03:02']] ethInfo5 = [['eth0', '2', '10.0.1.2', '255.255.255.0', '10.0.1.255']] # host2 networkSettings = [['Host1', 'generic', ethInfo1, ''], ['Bridge1', 'bridge', ethInfo2, ''], ['Bridge2', 'bridge', ethInfo3, ''], ['Bridge3', 'bridge', ethInfo4, ''], ['Host2', 'generic', ethInfo5, '']]
Opdracht 4
networkName = 'Opdracht4' numOfSubnets = 3 ethInfo1 = [['eth0', '1', '10.0.1.1', '255.255.255.0', '10.0.1.255']] # host1 ethInfo2 = [['eth0', '1', '00:30:48:28:01:01'], # bridge1 ['eth1', '2', '00:30:48:28:01:02']] ethInfo3 = [['eth0', '2', '00:30:48:28:02:01'], # bridge2 ['eth1', '3', '00:30:48:28:02:02']] ethInfo4 = [['eth0', '3', '10.0.1.2', '255.255.255.0', '10.0.1.255']] # host2 networkSettings = [['Host1', 'generic', ethInfo1, ''], ['Bridge1', 'bridge', ethInfo2, ''], ['Bridge2', 'bridge', ethInfo3, ''], ['Host2', 'generic', ethInfo4, '']]
Opdracht 5
networkName = 'Opdracht5' numOfSubnets = 4 ethInfo1 = [['eth0', '1', '10.0.1.1', '255.255.255.0', '10.0.1.255']] # host1 ethInfo2 = [['eth0', '1', '00:30:48:28:01:01'], # bridge1 ['eth1', '2', '00:30:48:28:01:02']] ethInfo3 = [['eth0', '2', '00:30:48:28:02:01'], # bridge2 ['eth1', '3', '00:30:48:28:02:02']] ethInfo4 = [['eth0', '3', '00:30:48:28:03:01'], # bridge3 ['eth1', '4', '00:30:48:28:03:02']] ethInfo5 = [['eth0', '4', '10.0.1.3', '255.255.255.0', '10.0.1.255']] # host2 networkSettings = [['Host1', 'generic', ethInfo1, ''], ['Bridge1', 'bridge', ethInfo2, ''], ['Bridge2', 'bridge', ethInfo3, ''], ['Bridge3', 'bridge', ethInfo4, ''], ['Host2', 'generic', ethInfo5, '']]
Opdracht 6
networkName = 'Opdracht6' numOfSubnets = 6 ethInfo1 = [['eth0', '1', '10.0.1.1', '255.255.255.0', '10.0.1.255']] # host1 ethInfo2 = [['eth0', '2', '10.0.1.2', '255.255.255.0', '10.0.1.255']] # host2 ethInfo3 = [['eth0', '3', '10.0.1.3', '255.255.255.0', '10.0.1.255']] # host3 ethInfo4 = [['eth0', '1', '00:30:48:28:01:01'], # bridge1 ['eth1', '4', '00:30:48:28:01:02'], ['eth2', '6', '00:30:48:28:01:03']] ethInfo5 = [['eth0', '2', '00:30:48:28:02:01'], # bridge2 ['eth1', '4', '00:30:48:28:02:02'], ['eth2', '5', '00:30:48:28:02:03']] ethInfo6 = [['eth0', '3', '00:30:48:28:03:01'], # bridge3 ['eth1', '5', '00:30:48:28:03:02'], ['eth2', '6', '00:30:48:28:03:03']] networkSettings = [['Host1', 'generic', ethInfo1, ''], ['Host2', 'generic', ethInfo2, ''], ['Host3', 'generic', ethInfo3, ''], ['Bridge1', 'bridge', ethInfo4, ''], ['Bridge2', 'bridge', ethInfo5, ''], ['Bridge3', 'bridge', ethInfo6, '']]
Opdracht 7
networkName = 'Opdracht7' numOfSubnets = 4 ethInfo1 = [['eth0', '1', '10.0.1.1', '255.255.255.0', '10.0.1.255']] # host1 ethInfo2 = [['eth0', '2', '10.0.1.2', '255.255.255.0', '10.0.1.255']] # host2 ethInfo3 = [['eth0', '3', '10.0.1.3', '255.255.255.0', '10.0.1.255']] # host3 ethInfo4 = [['eth0', '1', '00:30:48:28:01:01'], # bridge1 ['eth1', '4', '00:30:48:28:01:02']] ethInfo5 = [['eth0', '2', '00:30:48:28:02:01'], # bridge2 ['eth1', '4', '00:30:48:28:02:02']] ethInfo6 = [['eth0', '3', '00:30:48:28:03:01'], # bridge3 ['eth1', '4', '00:30:48:28:03:02']] networkSettings = [['Host1', 'generic', ethInfo1, ''], ['Host2', 'generic', ethInfo2, ''], ['Host3', 'generic', ethInfo3, ''], ['Bridge1', 'bridge', ethInfo4, ''], ['Bridge2', 'bridge', ethInfo5, ''], ['Bridge3', 'bridge', ethInfo6, '']]
Opdracht 8
networkName = 'Opdracht8' numOfSubnets = 8 ethInfo1 = [['eth0', '1', '10.0.1.1', '255.255.255.0', '10.0.1.255']] # host1 ethInfo2 = [['eth0', '2', '10.0.1.2', '255.255.255.0', '10.0.1.255']] # host2 ethInfo3 = [['eth0', '3', '10.0.1.3', '255.255.255.0', '10.0.1.255']] # host3 ethInfo4 = [['eth0', '4', '10.0.1.4', '255.255.255.0', '10.0.1.255']] # host4 ethInfo5 = [['eth0', '1', '00:30:48:28:01:01'], # bridge1 ['eth1', '5', '00:30:48:28:01:02'], ['eth2', '8', '00:30:48:28:01:03']] ethInfo6 = [['eth0', '2', '00:30:48:28:02:01'], # bridge2 ['eth1', '5', '00:30:48:28:02:02'], ['eth2', '6', '00:30:48:28:02:03']] ethInfo7 = [['eth0', '3', '00:30:48:28:03:01'], # bridge3 ['eth1', '6', '00:30:48:28:03:02'], ['eth2', '7', '00:30:48:28:03:03']] ethInfo8 = [['eth0', '3', '00:30:48:28:04:01'], # bridge4 ['eth1', '7', '00:30:48:28:04:02'], ['eth2', '8', '00:30:48:28:04:03']] networkSettings = [['Host1', 'generic', ethInfo1, ''], ['Host2', 'generic', ethInfo2, ''], ['Host3', 'generic', ethInfo3, ''], ['Host4', 'generic', ethInfo4, ''], ['Bridge1', 'bridge', ethInfo5, ''], ['Bridge2', 'bridge', ethInfo6, ''], ['Bridge3', 'bridge', ethInfo7, ''], ['Bridge4', 'bridge', ethInfo8, '']]
Opdracht 9
networkName = 'Opdracht9' numOfSubnets = 5 ethInfo1 = [['eth0', '1', '10.0.1.1', '255.255.255.0', '10.0.1.255']] # host1 ethInfo2 = [['eth0', '2', '10.0.1.2', '255.255.255.0', '10.0.1.255']] # host2 ethInfo3 = [['eth0', '3', '10.0.1.3', '255.255.255.0', '10.0.1.255']] # host3 ethInfo4 = [['eth0', '4', '10.0.1.4', '255.255.255.0', '10.0.1.255']] # host4 ethInfo5 = [['eth0', '1', '00:30:48:28:01:01'], # bridge1 ['eth1', '5', '00:30:48:28:01:02']] ethInfo6 = [['eth0', '2', '00:30:48:28:02:01'], # bridge2 ['eth1', '5', '00:30:48:28:02:02']] ethInfo7 = [['eth0', '3', '00:30:48:28:03:01'], # bridge3 ['eth1', '5', '00:30:48:28:03:02']] ethInfo8 = [['eth0', '3', '00:30:48:28:04:01'], # bridge4 ['eth1', '5', '00:30:48:28:04:02']] networkSettings = [['Host1', 'generic', ethInfo1, ''], ['Host2', 'generic', ethInfo2, ''], ['Host3', 'generic', ethInfo3, ''], ['Host4', 'generic', ethInfo4, ''], ['Bridge1', 'bridge', ethInfo5, ''], ['Bridge2', 'bridge', ethInfo6, ''], ['Bridge3', 'bridge', ethInfo7, ''], ['Bridge4', 'bridge', ethInfo8, '']]