1.Switch Configuration of packet tracer
1.Switch Configuration of packet tracer
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:
---
Procedure/Steps:
Enable Telnet and configure a password for remote access. Example commands:
Switch> enable
Switch(config-if)# no shutdown
Switch(config-line)# login
Switch(config-line)# exit
Switch(config)# exit
Use the telnetlib module to connect to the switch and retrieve the configuration details.
4. Execute the Program:
Verify the details retrieved by the script match the switch's default configuration.
---
Python Program:
import telnetlib
# Switch details
try:
# Enter password
tn.read_until(b"Password: ")
tn.write(PASSWORD.encode('ascii') + b"\n")
tn.write(b"show running-config\n")
tn.write(b"exit\n")
output = tn.read_all().decode('ascii')
print(output)
except Exception as e:
---
Output:
The output will display the default configuration of the switch, which includes:
Example snippet:
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.