Selasa, 08 Desember 2020

Backup Config Multiple Device

 Backup Config Multiple Device






Supaya seluruh device bisa di automasi, kita harus menambahkan link management ke ubuntu 


Ubuntu

root@NetworkAutomation-1:~#nano

backupmultiple.py root@NetworkAutomation1:~# cat backupmultiple.py import paramiko

import time

ip_list = ["192.168.10.2","192.168.10.3",

 "192.168.10.4","192.168.10.5"]

username = "cisco"

password = "cisco123"

ssh_client = paramiko.SSHClient()

ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

for ip_address in ip_list:

ssh_client.connect(hostname=ip_address,

 username=username,

 password=password)

print "Success login to {0}".format(ip_address)

conn = ssh_client.invoke_shell()

conn.send("terminal length 0\n")

conn.send("show run\n")

time.sleep(4)

output = conn.recv(65535)

output_file = open("{0}.cfg".format(ip_address), "w")

output_file.write(output)

output_file.close()

print "Config in {0} saved!!\n".format(ip_address)

ssh_client.close()


Script ini  hanya berfungsi menambahkan list IP Address dari seluruh router dan melakukan looping di list tersebut. 


Ubuntu

root@NetworkAutomation-1:~# python backupmultiple.py

Success login to 192.168.10.2

Config in 192.168.10.2 saved!!


Success login to

192.168.10.3 Config in

192.168.10.3 saved!!


Success login to 192.168.10.4

Config in 192.168.10.4 saved!!


Success login to 192.168.10.5

Config in 192.168.10.5 saved!!


Sekarang kita bisa lihat bahwa konfigurasi seluruh device nya sudah dibackup ,maka sekarang kita cek


Ubuntu

root@NetworkAutomation-1:~# ls | grep .cfg

192.168.10.2. cfg

192.168.10.3. cfg

192.168.10.4. cfg

192.168.10.5. cfg


Sekarang kita akan coba lihat isi dari salah satu file tersebut.


Ubuntu

root@NetworkAutomation-1:~# more 192.168.10.5.cfg

R4#terminal length 0

R4#showrun

Building configuration...

Current configuration : 1222 bytes

!

version 12.4

service timestamps debug

datetime msec service

timestamps log datetime msec

no service password-encryption

!

hostname R4

Tidak ada komentar:

Posting Komentar

LAB 1 FORTIGATE BASIC KONFIG

BASIC KONFIG FORTIGATE     Assalamualaikum Warahmatullahi Wabarakaatuh.....       Yaa...  jadi kali ini saya akan menjelaskan tutorial basic...