1 00:00:00,411 --> 00:00:06,429 In the previous video, we already learn how to create multiple interface at once, 2 00:00:07,126 --> 00:00:13,820 now in this video, we are going to learn how to configure multiple router at once. 3 00:00:14,369 --> 00:00:21,514 So for example here, in the gns3, we have router 1 until router 5, 4 00:00:22,026 --> 00:00:26,226 Let’s try to configure on all router at once. 5 00:00:27,591 --> 00:00:31,331 Let’s just start, create a new file, 6 00:00:35,000 --> 00:00:40,640 let’s say the name is paramiko_looping_router.py. 7 00:00:43,097 --> 00:00:48,623 And then let’s copy paste the script from paramiko_basic.py. 8 00:00:51,866 --> 00:00:56,140 Here we ask the input about ip address. 9 00:00:56,709 --> 00:01:00,771 But now we will looping to all router at once, 10 00:01:00,951 --> 00:01:08,569 so we don’t need to ask an input about ip address anymore. Let’s just remove this. 11 00:01:09,494 --> 00:01:12,626 But we still need username and password. 12 00:01:13,343 --> 00:01:21,471 Now let’s define a looping here. We can start the looping here in the connect section. 13 00:01:22,077 --> 00:01:28,989 Why here? Because for username password, ssh client 14 00:01:29,123 --> 00:01:37,746 and set missing host key policy will be same for all router, so we don’t need to looping here. 15 00:01:38,223 --> 00:01:41,586 We will start the looping in the connect section, 16 00:01:41,729 --> 00:01:46,720 because the ip address of each router is different. 17 00:01:47,320 --> 00:01:55,994 We will looping with very basic case, if we see the ip address of all router, they have a pattern, 18 00:01:56,229 --> 00:02:06,489 the ip address is 10.10.10 and then the router number, so router 1 is 10.10.10.1, 19 00:02:06,686 --> 00:02:18,094 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 00:02:19,686 --> 00:02:30,974 So we can looping on the last number, here for x, x is just variable, you can use anything, 21 00:02:31,583 --> 00:02:40,757 in range 1 until 6, this is means that we will looping start from 1 until 5. 22 00:02:41,677 --> 00:02:50,983 And then we can add indentation here, so all script until close will be the part of looping. 23 00:02:51,734 --> 00:03:00,670 For the hostname, we can change it become like this, 10.10.10. and then the router number, 24 00:03:01,280 --> 00:03:10,700 so router 1 should be 10.10.10.1, router 2 should be 10.10.10.2 and others. 25 00:03:11,371 --> 00:03:16,903 In this case, for router number, we can use variable x, 26 00:03:17,386 --> 00:03:23,280 so here we will use f string, and then x here. 27 00:03:23,866 --> 00:03:32,871 When the value of x is 1, this script will remote router 1, when the value of x is 2, 28 00:03:32,940 --> 00:03:37,100 the script will remote router 2, and others. 29 00:03:38,320 --> 00:03:40,483 The username and password is same on 30 00:03:40,483 --> 00:03:46,340 all router. And then here we can see that the script is too long. 31 00:03:46,609 --> 00:04:03,406 We can enter the script after comma like this, Okay so now the script is look good. 32 00:04:03,983 --> 00:04:10,997 Next here, we can change this become 10.10.10.x, 33 00:04:12,929 --> 00:04:19,583 Here invoke shell, configure terminal, and then interface loopback0, 34 00:04:20,077 --> 00:04:25,266 For ip address, let’s configure the different ip address for each router, 35 00:04:25,466 --> 00:04:30,689 let’s say router 1, the ip address will be 10.1.1.1, 36 00:04:30,854 --> 00:04:41,497 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 00:04:42,237 --> 00:04:46,103 So here we can change this become x. 38 00:04:46,571 --> 00:04:51,566 F string here, and then let’s change this become x. 39 00:04:52,571 --> 00:05:01,143 After send the command, we save the output, print the output, and last, close the ssh connection. 40 00:05:01,917 --> 00:05:05,222 Okay we have done here. Save, 41 00:05:08,863 --> 00:05:20,549 let’s back to the terminal, ls, here we can see that we have paramiko_looping_router.py. 42 00:05:21,269 --> 00:05:23,583 let’s execute this script. 43 00:05:25,371 --> 00:05:31,854 Here we don’t need to input ip address anymore, but we still need to input username, 44 00:05:32,200 --> 00:05:37,840 just enter here, for password, we also can just enter. 45 00:05:38,420 --> 00:05:55,514 First the script will configure router 1, and then router 2, router 3, router 4, and last router 5. 46 00:05:56,260 --> 00:06:01,580 Okay so now we are success to configure multiple router at once. 47 00:06:02,469 --> 00:06:12,169 For the testing, let’s check the interface on all router, router 1, show ip interface brief, 48 00:06:16,483 --> 00:06:19,591 here we can see that we have loopback0, 49 00:06:21,189 --> 00:06:22,594 Router 2, 50 00:06:26,149 --> 00:06:29,567 show ip interface brief exclude unassign, 51 00:06:31,306 --> 00:06:37,563 here we also have loopback0, the ip address is 10.1.1.2. 52 00:06:38,323 --> 00:06:39,643 router 3, 53 00:06:43,471 --> 00:06:56,339 do show ip interface brief exclude unassign, here we also have loopback0, the ip address is 10.1.1.3, 54 00:06:58,525 --> 00:07:00,000 router 4, 55 00:07:03,984 --> 00:07:16,114 do show ip interface brief exclude unassign, here we also have loopback0, the ip address is 10.1.1.4, 56 00:07:16,700 --> 00:07:18,787 and last, router 5, 57 00:07:23,716 --> 00:07:27,526 do show ip interface brief exclude unassign, 58 00:07:31,009 --> 00:07:38,809 here we can see that we also have loopback0, the ip address is 10.1.1.5. 59 00:07:39,840 --> 00:07:44,490 Okay so now we are success to configure multiple router at once. 60 00:07:45,061 --> 00:07:47,606 I think enough for this video, 61 00:07:47,683 --> 00:07:51,286 Thank you for watching and see you on the next video.