1 00:00:00,600 --> 00:00:02,640 So let's save our script. 2 00:00:04,620 --> 00:00:11,550 And what I'll do is use Python three to run this Python script before I run the script. 3 00:00:11,640 --> 00:00:14,070 Let's run a debug on the router. 4 00:00:14,160 --> 00:00:21,060 So debug telnet that will allow us to see if any connections are made to the router. 5 00:00:22,620 --> 00:00:26,370 After the moment, I'm connected to the console of the writer. 6 00:00:26,880 --> 00:00:28,140 So run the script. 7 00:00:28,170 --> 00:00:29,820 We prompted for our username. 8 00:00:30,000 --> 00:00:31,950 We prompted for our password. 9 00:00:34,970 --> 00:00:41,600 And notice we can see that the script telnet to the router and we can see that a loopback interface 10 00:00:41,600 --> 00:00:42,560 came up. 11 00:00:42,590 --> 00:00:45,080 So show IP interface brief. 12 00:00:46,040 --> 00:00:49,400 The loopback has been configured on the router. 13 00:00:50,120 --> 00:00:59,180 Our script also shows us what it saw, so when it telnet it to the router it got to the output typed 14 00:00:59,180 --> 00:01:07,670 enable was prompted for the enable password typed that logically into the router typed quantity created 15 00:01:07,670 --> 00:01:13,750 the loopback typed end typed exit and the session has now ended. 16 00:01:13,760 --> 00:01:19,160 So again, nano python 3.1 that simple script. 17 00:01:19,950 --> 00:01:24,090 Talent added to the rotter and created a loopback on the router. 18 00:01:24,450 --> 00:01:31,830 It's as simple as that to configure network devices such as Cisco routers using Python. 19 00:01:32,310 --> 00:01:35,610 What I could do as an example is expand the script. 20 00:01:36,210 --> 00:01:38,010 So let's create another loopback. 21 00:01:38,130 --> 00:01:39,420 Loopback one. 22 00:01:40,150 --> 00:01:44,170 And configure an IP address on that loopback. 23 00:01:44,470 --> 00:01:46,200 And I'll save the script. 24 00:01:47,050 --> 00:01:48,160 Clear the screen. 25 00:01:50,150 --> 00:01:53,120 On the router show IP interface brief notice. 26 00:01:53,120 --> 00:01:57,110 We only have a loopback zero under the router. 27 00:01:57,950 --> 00:02:02,330 I'll run the script again into my username and to my password. 28 00:02:03,470 --> 00:02:09,080 Script has telnet to the router and you can see that another loopback interface has come up. 29 00:02:09,440 --> 00:02:16,910 You can also see here that David configured the router via V line is zero. 30 00:02:17,330 --> 00:02:21,200 Show line shows us that the connection was disconnected. 31 00:02:21,350 --> 00:02:31,640 Remember we typed exit here to exit the telnet session, but show IP interface brief shows us that that 32 00:02:31,730 --> 00:02:34,220 loopback now exists on the router. 33 00:02:34,760 --> 00:02:42,290 Show IP protocols shows us that no routing protocols are enabled on the router at this point, but we 34 00:02:42,290 --> 00:02:49,300 could use our Python script to enable OSPF or other writing protocols on the router. 35 00:02:49,310 --> 00:02:54,500 So as an example, we could simply edit our script. 36 00:02:56,590 --> 00:03:00,730 Copy some lines, paste them into the script. 37 00:03:03,200 --> 00:03:06,290 And enable a routing protocol such as OSPF. 38 00:03:09,080 --> 00:03:12,770 And send network commands directly to the router. 39 00:03:13,130 --> 00:03:19,400 So something like a network 0000245245245245. 40 00:03:19,820 --> 00:03:20,990 Area zero. 41 00:03:21,950 --> 00:03:23,120 Save the script. 42 00:03:23,720 --> 00:03:28,430 So again, no routing protocols are currently enabled on the router. 43 00:03:28,970 --> 00:03:30,860 But if I run my script. 44 00:03:34,480 --> 00:03:36,610 And use the command again. 45 00:03:36,610 --> 00:03:38,050 Show IP protocols. 46 00:03:38,230 --> 00:03:42,070 Notice OSPF has now been enabled on the router. 47 00:03:42,280 --> 00:03:49,570 Show IP OSPF interface brief shows us that OSPF is running on those three interfaces. 48 00:03:50,290 --> 00:03:51,400 So there you go. 49 00:03:54,010 --> 00:04:00,100 A basic script in Python can be used to automate Cisco network devices. 50 00:04:00,640 --> 00:04:05,020 Now, please don't lose sight of the fact that this is the beginning. 51 00:04:05,230 --> 00:04:07,420 This is a very basic script. 52 00:04:07,660 --> 00:04:10,100 It's doing basic things. 53 00:04:10,120 --> 00:04:18,670 We can use loops and other Python logic to make our scripts far more versatile and far more powerful. 54 00:04:18,940 --> 00:04:25,300 This is a simple start, but hopefully shows you what's possible with Python. 55 00:04:26,400 --> 00:04:27,180 Again. 56 00:04:27,480 --> 00:04:37,080 If I remove OSPF from the router and remove the loopback interfaces on the router, I can simply rerun 57 00:04:37,080 --> 00:04:40,680 the script to add the loopback interfaces back. 58 00:04:42,540 --> 00:04:45,420 And to enable OSPF on the router. 59 00:04:46,660 --> 00:04:48,910 So again, run the script. 60 00:04:50,710 --> 00:04:54,370 It applies the configuration back to the router. 61 00:04:54,820 --> 00:04:56,530 Show IP protocols. 62 00:04:56,950 --> 00:04:58,690 Need to put my password in there. 63 00:04:58,690 --> 00:04:59,710 I made a mistake. 64 00:05:00,530 --> 00:05:02,390 So David, Cisco. 65 00:05:04,380 --> 00:05:04,870 There you go. 66 00:05:04,890 --> 00:05:05,940 That's been done. 67 00:05:06,210 --> 00:05:08,340 So show IP protocols. 68 00:05:08,460 --> 00:05:10,060 OSPF is now running. 69 00:05:10,080 --> 00:05:11,490 Show IP interface. 70 00:05:11,490 --> 00:05:13,440 Brief loopback. 71 00:05:13,450 --> 00:05:14,430 So back again. 72 00:05:14,610 --> 00:05:17,430 This is a paradigm or way of thinking. 73 00:05:17,430 --> 00:05:20,730 Change to normal network configurations. 74 00:05:21,090 --> 00:05:30,840 You can store your configurations on a network automation server or computer and then make sure that 75 00:05:30,840 --> 00:05:37,140 your devices have a consistent and authorized configuration applied to them. 76 00:05:37,320 --> 00:05:45,090 So if someone changes the configuration of a router or makes a mistake, you can simply use a configuration 77 00:05:45,090 --> 00:05:53,910 stored on a network automation server to apply the configurations back to the devices in your network. 78 00:05:55,120 --> 00:05:58,750 Now again, this is very simple, but is a way to get started. 79 00:05:59,530 --> 00:06:04,210 We'll iterate and improve on this code as we go through the course.