In the previous video, we already learn how to looping in the list, 2
so here we have the list of ip address of all router, and then we do looping to the list. 3
But we only configure 1 interface on each router. 4
Now in this video, we are going to configure multiple interface in all router at once. 5
So we will have 2 looping. The first looping is looping to all router, 6
and then for each router, we will do looping again to create multiple interface. 7
We usually called this method as nested looping, so we have looping inside looping. 8
Okay let’s just start, copy this script, create new file, 9
let’s say the name is paramiko_looping_nested.py, 10
And then paste the script here. 11
So here we already have the list ip address of all router, 12
and then here we already looping to the list_ip, 13
Next here, let’s add script to configure let’s say loopback 6 until 8. 14
Here we already have loopback5, so we will create loopback6 until 8. 15
Let’s looping here, for x in range , x is just a variable, 16
you are free to use anything. And then range 17
6 until 9. Because we want to create interface loopback 6 until 8, so we do looping from 6 to 9. 18
Now let’s put this script inside looping, 19
we just need to do write one time each router, so we don’t need to put this script inside looping. 20
We also just need to configure terminal one time, so this is also will be outside the looping. 21
Next, here for the loopback number, 22
let’s change this to x, so here we need to use f string, and then change this to x. 23
For the ip address, this is the number of loopback increment by 1, 24
when we create loopback5, the number is 6, when we create loopback4, the number is 5, 25
So here we can change this become x + 1. So when we create loopback 6, the number will be 7. 26
When we create loopback7, the number will be 8, and when we create loopback8, the number will be 9. 27
For the last number will be still the router_id, 28
Okay done here, save, let’s back to the terminal, ls, here we can see that we 29
have paramiko_looping_nested. Let’s execute this. Just enter enter here. 30
Okay success login to router 1, and we are success to create loopback 6 until 8 in router 1, 31
Router 2 also successs, router 3 success, router 4 success, and router 5 also success. 32
Okay so now we are success to do nested looping, which is looping inside looping. 33
I think enough for this video 34
Thank you for watching and see you on the next video.