From f83e35bb1ebcb673c398d6f0dd20e8acb6b1688d Mon Sep 17 00:00:00 2001 From: bmzsombi <bmzsombi@sch.bme.hu> Date: Thu, 25 May 2023 14:23:33 +0200 Subject: [PATCH] Lab almost configured, basic py script --- lab/lab.yaml | 212 +++++++++++++++++++++++++++++++++++++++++++++++ maskrecover.py | 12 +++ networks.txt | 2 + plays/test.yaml | 4 +- router1.txt | 16 ++++ router1_ip.txt | 2 + router1_mask.txt | 2 + router_config | 25 ++++++ sort.sh | 2 + 9 files changed, 275 insertions(+), 2 deletions(-) create mode 100644 lab/lab.yaml create mode 100755 maskrecover.py create mode 100644 networks.txt create mode 100644 router1.txt create mode 100644 router1_ip.txt create mode 100644 router1_mask.txt create mode 100644 router_config create mode 100755 sort.sh diff --git a/lab/lab.yaml b/lab/lab.yaml new file mode 100644 index 0000000..fc6071a --- /dev/null +++ b/lab/lab.yaml @@ -0,0 +1,212 @@ +lab: + description: '' + notes: '' + title: Lab at Thu 10:04 AM + version: 0.2.0 +links: + - id: l0 + n1: n0 + n2: n1 + i1: i0 + i2: i0 + label: ext-conn-0-port<->unmanaged-switch-0-port0 + - id: l1 + n1: n1 + n2: n2 + i1: i1 + i2: i1 + label: unmanaged-switch-0-port1<->iosv-0-GigabitEthernet0/0 + - id: l2 + n1: n1 + n2: n3 + i1: i2 + i2: i1 + label: unmanaged-switch-0-port2<->iosv-1-GigabitEthernet0/0 + - id: l3 + n1: n2 + n2: n3 + i1: i2 + i2: i2 + label: iosv-0-GigabitEthernet0/1<->iosv-1-GigabitEthernet0/1 + - id: l4 + n1: n4 + n2: n1 + i1: i1 + i2: i3 + label: iosv-2-GigabitEthernet0/0<->unmanaged-switch-0-port3 + - id: l5 + n1: n4 + n2: n2 + i1: i2 + i2: i3 + label: iosv-2-GigabitEthernet0/1<->iosv-0-GigabitEthernet0/2 +nodes: + - boot_disk_size: null + configuration: bridge0 + cpu_limit: null + cpus: null + data_volume: null + hide_links: false + id: n0 + image_definition: null + label: ext-conn-0 + node_definition: external_connector + ram: null + tags: [] + x: -200 + y: 160 + interfaces: + - id: i0 + label: port + slot: 0 + type: physical + - boot_disk_size: null + configuration: ums-bb1640ec-7a + cpu_limit: null + cpus: null + data_volume: null + hide_links: false + id: n1 + image_definition: null + label: unmanaged-switch-0 + node_definition: unmanaged_switch + ram: null + tags: [] + x: -40 + y: 40 + interfaces: + - id: i0 + label: port0 + slot: 0 + type: physical + - id: i1 + label: port1 + slot: 1 + type: physical + - id: i2 + label: port2 + slot: 2 + type: physical + - id: i3 + label: port3 + slot: 3 + type: physical + - id: i4 + label: port4 + slot: 4 + type: physical + - id: i5 + label: port5 + slot: 5 + type: physical + - id: i6 + label: port6 + slot: 6 + type: physical + - id: i7 + label: port7 + slot: 7 + type: physical + - boot_disk_size: null + configuration: hostname inserthostname-here + cpu_limit: null + cpus: null + data_volume: null + hide_links: false + id: n2 + image_definition: null + label: iosv-0 + node_definition: iosv + ram: null + tags: [] + x: 200 + y: -40 + interfaces: + - id: i0 + label: Loopback0 + type: loopback + - id: i1 + label: GigabitEthernet0/0 + slot: 0 + type: physical + - id: i2 + label: GigabitEthernet0/1 + slot: 1 + type: physical + - id: i3 + label: GigabitEthernet0/2 + slot: 2 + type: physical + - id: i4 + label: GigabitEthernet0/3 + slot: 3 + type: physical + - boot_disk_size: null + configuration: hostname inserthostname-here + cpu_limit: null + cpus: null + data_volume: null + hide_links: false + id: n3 + image_definition: null + label: iosv-1 + node_definition: iosv + ram: null + tags: [] + x: 0 + y: -120 + interfaces: + - id: i0 + label: Loopback0 + type: loopback + - id: i1 + label: GigabitEthernet0/0 + slot: 0 + type: physical + - id: i2 + label: GigabitEthernet0/1 + slot: 1 + type: physical + - id: i3 + label: GigabitEthernet0/2 + slot: 2 + type: physical + - id: i4 + label: GigabitEthernet0/3 + slot: 3 + type: physical + - boot_disk_size: null + configuration: hostname inserthostname-here + cpu_limit: null + cpus: null + data_volume: null + hide_links: false + id: n4 + image_definition: null + label: iosv-2 + node_definition: iosv + ram: null + tags: [] + x: 440 + y: 40 + interfaces: + - id: i0 + label: Loopback0 + type: loopback + - id: i1 + label: GigabitEthernet0/0 + slot: 0 + type: physical + - id: i2 + label: GigabitEthernet0/1 + slot: 1 + type: physical + - id: i3 + label: GigabitEthernet0/2 + slot: 2 + type: physical + - id: i4 + label: GigabitEthernet0/3 + slot: 3 + type: physical +annotations: [] diff --git a/maskrecover.py b/maskrecover.py new file mode 100755 index 0000000..d75c0aa --- /dev/null +++ b/maskrecover.py @@ -0,0 +1,12 @@ +def read_file(): + ip_path = "router1_ip.txt" + mask_path = "router1_mask.txt" + + with open(ip_path, "r") as file: + lines = file.readlines() + for line in lines: + print(line.strip()) + + +if __name__ == "__main__": + read_file() diff --git a/networks.txt b/networks.txt new file mode 100644 index 0000000..f282cf0 --- /dev/null +++ b/networks.txt @@ -0,0 +1,2 @@ +router1 - gi0/1 - 10.10.20.169 -- network: .129-.174 - 255.255.255.248 +router2 - gi0/1 - 10.10.20.177 -- network: .177-.182 diff --git a/plays/test.yaml b/plays/test.yaml index c6faf25..bc886d7 100644 --- a/plays/test.yaml +++ b/plays/test.yaml @@ -6,10 +6,10 @@ tasks: - name: Show int info cisco.ios.ios_command: - commands: show ip route vrf Mgmt-intf + commands: show ip static route register: interfaces_info - name: Print output copy: content: "{{interfaces_info.stdout[0]}}" - dest: ~/onlab/{{inventory_hostname}}.txt \ No newline at end of file + dest: ~/onlab/{{inventory_hostname}}.txt diff --git a/router1.txt b/router1.txt new file mode 100644 index 0000000..4cf3cb5 --- /dev/null +++ b/router1.txt @@ -0,0 +1,16 @@ +Codes: M - Manual static, A - AAA download, N - IP NAT, D - DHCP, + G - GPRS, V - Crypto VPN, C - CASA, P - Channel interface processor, + B - BootP, S - Service selection gateway + DN - Default Network, T - Tracking object + L - TL1, E - OER, I - iEdge + D1 - Dot1x Vlan Network, K - MWAM Route + PP - PPP default route, MR - MRIPv6, SS - SSLVPN + H - IPe Host, ID - IPe Domain Broadcast + U - User GPRS, TE - MPLS Traffic-eng, LI - LIIN + IR - ICMP Redirect +Codes in []: A - active, N - non-active, B - BFD-tracked, D - Not Tracked, P - permanent + +Static local RIB for default + +M 10.10.20.160/29 [1/0] via 10.10.20.177 [N] +M 10.10.20.176/29 [1/0] via 10.10.20.177 [N] \ No newline at end of file diff --git a/router1_ip.txt b/router1_ip.txt new file mode 100644 index 0000000..382cf6a --- /dev/null +++ b/router1_ip.txt @@ -0,0 +1,2 @@ +10.10.20.160 +10.10.20.176 diff --git a/router1_mask.txt b/router1_mask.txt new file mode 100644 index 0000000..bae7f4f --- /dev/null +++ b/router1_mask.txt @@ -0,0 +1,2 @@ +29 +29 diff --git a/router_config b/router_config new file mode 100644 index 0000000..32adc7d --- /dev/null +++ b/router_config @@ -0,0 +1,25 @@ +enable +configure terminal +hostname R3 +enable secret cisco +! +username bmzsombi secret cisco +ip domain-name onlab +crypto key generate rsa modulus 2048 +ip ssh version 2 +! +line vty 0 4 +transport input ssh +login local +! +exit +vrf definition Mgmt-intf +address-family ipv4 +interface g0/0 +vrf forwarding Mgmt-intf +ip address 10.10.20.102 255.255.255.0 +no shutdown +exit +ip route vrf Mgmt-intf 0.0.0.0 0.0.0.0 10.10.20.254 +end +wr diff --git a/sort.sh b/sort.sh new file mode 100755 index 0000000..6ac5462 --- /dev/null +++ b/sort.sh @@ -0,0 +1,2 @@ +cat router1.txt | grep "^M" | cut -d' ' -f3 | cut -d'/' -f1 >> router1_ip.txt +cat router1.txt | grep "^M" | cut -d' ' -f3 | cut -d'/' -f2 >> router1_mask.txt -- GitLab