0% found this document useful (0 votes)
18 views

1.Switch Configuration of packet tracer

The document outlines a practical exam for verifying the default configuration of a Cisco switch in Packet Tracer using a Python program. It details the necessary apparatus, steps for setting up the network, enabling Telnet access, writing and executing the Python script, and analyzing the output. The successful execution of the program retrieves and verifies the switch's default configuration details.

Uploaded by

TC Mathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

1.Switch Configuration of packet tracer

The document outlines a practical exam for verifying the default configuration of a Cisco switch in Packet Tracer using a Python program. It details the necessary apparatus, steps for setting up the network, enabling Telnet access, writing and executing the Python script, and analyzing the output. The successful execution of the program retrieves and verifies the switch's default configuration details.

Uploaded by

TC Mathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Subject Name: Network Essentials

Practical Exam

Topic:

To Verify the Default Switch Configuration of Packet Tracer Using a Short Python
Program

---

Aim:

To verify the default configuration of a switch in Cisco Packet Tracer using Python
programming and retrieve basic details like switch name, interfaces, VLANs, and port
status.

---

Apparatus Required:

1. Cisco Packet Tracer software

2. A computer system with Python installed


3. Python script editor (e.g., IDLE, VS Code)

4. Basic understanding of the telnetlib Python module

5. Pre-configured Packet Tracer switch (default configuration)

---

Procedure/Steps:

1. Setup the Network in Packet Tracer:

Add a Cisco switch to the workspace.

Connect a PC to the switch using a straight-through cable.

Assign an IP address to the PC to communicate with the switch (e.g., 192.168.1.2/24).


2. Enable Telnet Access on the Switch:

Access the switch through the CLI in Packet Tracer.

Configure a basic IP address on the VLAN 1 interface (e.g., 192.168.1.1/24).

Enable Telnet and configure a password for remote access. Example commands:

Switch> enable

Switch# configure terminal

Switch(config)# interface vlan 1

Switch(config-if)# ip address 192.168.1.1 255.255.255.0

Switch(config-if)# no shutdown

Switch(config)# line vty 0 4

Switch(config-line)# password cisco

Switch(config-line)# login

Switch(config-line)# exit

Switch(config)# exit

3. Write the Python Program:

Use the telnetlib module to connect to the switch and retrieve the configuration details.
4. Execute the Program:

Run the Python script from your editor or terminal.

5. Analyze the Output:

Verify the details retrieved by the script match the switch's default configuration.

---

Python Program:

import telnetlib

# Switch details

HOST = "192.168.1.1" # Switch IP address

USER = "" # Default username (leave empty if not set)


PASSWORD = "cisco" # Telnet password

try:

# Connect to the switch


tn = telnetlib.Telnet(HOST)

# Enter password

tn.read_until(b"Password: ")

tn.write(PASSWORD.encode('ascii') + b"\n")

# Send command to show default configuration

tn.write(b"show running-config\n")
tn.write(b"exit\n")

# Read and print the output

output = tn.read_all().decode('ascii')

print("Switch Configuration Output:\n")

print(output)

except Exception as e:

print("Error connecting to the switch:", e)

---

Output:

The output will display the default configuration of the switch, which includes:

Hostname (default: Switch)


VLAN configurations (default: VLAN 1)

Interfaces (e.g., FastEthernet or GigabitEthernet)

Line configurations (vty and console)

Example snippet:

Switch Configuration Output:

version 15.0

hostname Switch

interface FastEthernet0/1

no shutdown

!
line vty 0 4

password cisco

login

---
Result:

The default configuration of the switch was successfully retrieved and verified using the
Python program.

You might also like