In the previous video, we already learn how to create multiple interface at once, 2
now in this video, we are going to learn how to configure multiple router at once. 3
So for example here, in the gns3, we have router 1 until router 5, 4
Let’s try to configure on all router at once. 5
Let’s just start, create a new file, 6
let’s say the name is paramiko_looping_router.py. 7
And then let’s copy paste the script from paramiko_basic.py. 8
Here we ask the input about ip address. 9
But now we will looping to all router at once, 10
so we don’t need to ask an input about ip address anymore. Let’s just remove this. 11
But we still need username and password. 12
Now let’s define a looping here. We can start the looping here in the connect section. 13
Why here? Because for username password, ssh client 14
and set missing host key policy will be same for all router, so we don’t need to looping here. 15
We will start the looping in the connect section, 16
because the ip address of each router is different. 17
We will looping with very basic case, if we see the ip address of all router, they have a pattern, 18
the ip address is 10.10.10 and then the router number, so router 1 is 10.10.10.1, 19
router 2 is 10.10.10.2, router 3 is 10.10.10.3, router 4 is 10.10.10.4 and router 5 is 10.10.10.5 20
So we can looping on the last number, here for x, x is just variable, you can use anything, 21
in range 1 until 6, this is means that we will looping start from 1 until 5. 22
And then we can add indentation here, so all script until close will be the part of looping. 23
For the hostname, we can change it become like this, 10.10.10. and then the router number, 24
so router 1 should be 10.10.10.1, router 2 should be 10.10.10.2 and others. 25
In this case, for router number, we can use variable x, 26
so here we will use f string, and then x here. 27
When the value of x is 1, this script will remote router 1, when the value of x is 2, 28
the script will remote router 2, and others. 29
The username and password is same on 30
all router. And then here we can see that the script is too long. 31
We can enter the script after comma like this, Okay so now the script is look good. 32
Next here, we can change this become 10.10.10.x, 33
Here invoke shell, configure terminal, and then interface loopback0, 34
For ip address, let’s configure the different ip address for each router, 35
let’s say router 1, the ip address will be 10.1.1.1, 36
router 2 let’s say will be 10.1.1.2, until router 5 let’s say the ip address will be 10.1.1.5. 37
So here we can change this become x. 38
F string here, and then let’s change this become x. 39
After send the command, we save the output, print the output, and last, close the ssh connection. 40
Okay we have done here. Save, 41
let’s back to the terminal, ls, here we can see that we have paramiko_looping_router.py. 42
let’s execute this script. 43
Here we don’t need to input ip address anymore, but we still need to input username, 44
just enter here, for password, we also can just enter. 45
First the script will configure router 1, and then router 2, router 3, router 4, and last router 5. 46
Okay so now we are success to configure multiple router at once. 47
For the testing, let’s check the interface on all router, router 1, show ip interface brief, 48
here we can see that we have loopback0, 49
Router 2, 50
show ip interface brief exclude unassign, 51
here we also have loopback0, the ip address is 10.1.1.2. 52
router 3, 53
do show ip interface brief exclude unassign, here we also have loopback0, the ip address is 10.1.1.3, 54
router 4, 55
do show ip interface brief exclude unassign, here we also have loopback0, the ip address is 10.1.1.4, 56
and last, router 5, 57
do show ip interface brief exclude unassign, 58
here we can see that we also have loopback0, the ip address is 10.1.1.5. 59
Okay so now we are success to configure multiple router at once. 60
I think enough for this video, 61
Thank you for watching and see you on the next video.