Network automation VLAN configuration using python scripts adalah mengconfig vlan pada dua buah switch secara bersamaan menggukan script yang telah saya buat sehingga vlan terconfig secara automatic pada kedua switch tanpa harus menggunakan CLI satu persatu.
Script Python :
..............................
import getpass
import telnetlib
HOST = "localhost"
user = input ("Enter your telnet username: ")
password = getpass.getpass()
hostFiles = open('swipaddress')
for IP in hostFiles:
IP = IP.strip()
print("Configuring Switch " + (IP))
HOST = IP
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"conf t\n")
for i in range (2,10):
tn.write(b"vlan " + str(i).encode('ascii') + b"\n")
tn.write(b"name Netauto_Py_" + str(i).encode('ascii') + b"\n")
tn.write(b"end\n")
tn.write(b"wr\n")
tn.write(b"exit\n")
print(tn.read_all().decode('ascii'))
-----------------------------------------------------
Tool yang digunakan :
GNS3
VIOS layar 3 switch
mohon dukunganya ya..
#Subscribes
#Likes
#Comments
#Everydaylearning