In the previous video, we already do nested looping, so we have looping inside looping, 2
the first looping is to looping on all router, and then for each router, we do looping to 3
configure multiple loopback interface. 4
But this script actually is not best practice. 5
For now, the ip address of all router is similar, the first 3 number is same, and the last number 6
is in sequence. 7
The problem is, if the ip address of all router is totally different. 8
So we can not looping like this. 9
The best way to configure multiple router at once is using a list, so we save the ip 10
address of all router in the list, and then we can do looping to the list. 11
Let’s just try it, copy this script. 12
Create new file, let’s say the name is netmiko_looping_list.py. 13
Paste the script. 14
Now let’s create the list to save the ip address of all router, 15
List_ip, and then let’s define the ip address of all router, 10.10.10.1, 10.10.10.2, 10.10.10.3, 16
this is to long, so we can enter here. 17
And then 10.10.10.4, and last 10.10.10.5. 18
Now we can do looping in the list, let’s say for ip in list_ip, 19
For the host, we can just use the ip variable. 20
Here we will connect to each router, let’s just remove the list config, so we will not 21
configure anything, we will just only show the interface. 22
Okay we have done here, save, back to the ubuntu server, ls, here we can see that we 23
have netmiko_looping_list.py, let’s execute this. 24
Router 1 success, router 2 success, rotuer 3 success, router 4 success, and router 5 is also succes. 25
So now we are success to remote multiple router at once using list. 26
I think enough for this video 27
Thank you for watching and see you on the next video.