Monday, 4 December 2017

Multiple Switch, Multiple Vlan

.
enable password cisco
username adrian privilege 15 password 0 cisco
!
line vty 0 4
 login local
 transport input all






host S2

int vlan 1 
no shut
 ip add 192.168.122.73 255.255.255.0
---

host S3

int vlan 1 
no shut
 ip add 192.168.122.74 255.255.255.0

--

host S4

int vlan 1 
no shut
 ip add 192.168.122.75 255.255.255.0
--

host S5

int vlan 1 
no shut
ip add 192.168.122.76 255.255.255.0





#!/usr/bin/env python
import getpass
import sys
import telnetlib
user = raw_input("Enter your telnet username: ")
password = getpass.getpass()
for n in range (72,77):
print "Telnet to host" + str(n)
HOST = "192.168.122." + str(n)
tn = telnetlib.Telnet(HOST)
tn.read_until("Username: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("conf t\n")
for n in range (2,21):
tn.write("vlan " + str(n) + "\n")
tn.write("name Python_VLAN_" + str(n) + "\n")
tn.write("end\n")
tn.write("exit\n")
print tn.read_all()

Result:















No comments:

Post a Comment

Demo: Interface Profiles

Create Leaf Interface Profile