Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNS3 Talks: Python for Network Engineers with GNS3 (Part 5) - Multiple switches, multiple VLANs - ISSUE #14

Open
moodhacker opened this issue Apr 14, 2023 · 0 comments

Comments

@moodhacker
Copy link

Hello David. Any reason why this only configure one switch? I am able to telnet from my SW1 to all the devices and also from my home laptop that run the script. Every time I ran it, it only configure SW4, if I reduce the range, it will take any of the random SW

#!/usr/local/bin/python3.9

import getpass
import sys
import telnetlib

user = input("Enter your telnet user name: ")
password = getpass.getpass()

for n in range (10,14):
HOST = "10.115.0." + str(n)
tn = telnetlib.Telnet(HOST)

tn.read_until(b"Username: ")
tn.write(user.encode('ascii') + b"\n")
if password:
    tn.read_until(b"Password: ")
    tn.write(password.encode('ascii') + b"\n")

tn.write(b"config t\n")

for n in range(2,11):
     tn.write(b"vlan " + str(n).encode('ascii') + b"\n")
     tn.write(b"name Python_VLAN_" + str(n).encode('ascii') + b"\n")

tn.write(b"end\n")
tn.write(b"write\n")
tn.write(b"exit\n")

print(tn.read_all().decode('ascii'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant