1 00:00:00,510 --> 00:00:06,210 This is a continuation of a series of videos where I'm teaching you to become a better network engineer 2 00:00:06,210 --> 00:00:12,250 and teaching you commands in the Cisco iOS that you may not have known about as we both disappear. 3 00:00:23,180 --> 00:00:24,440 Please do me a favor. 4 00:00:24,830 --> 00:00:28,880 Put a comment below this video and let me know when you've learned something. 5 00:00:28,880 --> 00:00:31,310 So put a timestamp on the video. 6 00:00:31,320 --> 00:00:34,310 So how far would did you get through the video before you learn something? 7 00:00:34,310 --> 00:00:35,900 Which command did you learn? 8 00:00:36,230 --> 00:00:41,300 If you've no commands that I haven't used or options that I haven't used, please add them below this 9 00:00:41,300 --> 00:00:44,300 video so that we can all learn from one another. 10 00:00:44,330 --> 00:00:46,250 I wish I knew everything, but I don't. 11 00:00:46,400 --> 00:00:48,560 I'm just sharing some tips and tricks that I know. 12 00:00:48,560 --> 00:00:54,560 But please also add your tips and tricks below this video because this is YouTube. 13 00:00:54,710 --> 00:00:57,360 Please, would you subscribe to my YouTube channel? 14 00:00:57,380 --> 00:00:58,640 Please, would you like this video? 15 00:00:58,640 --> 00:01:03,680 If you find it useful and please click on the bell to get notifications when I post a new video. 16 00:01:03,800 --> 00:01:09,350 In this video I'm going to show you some Linux commands that you can run on Cisco iOS that will hopefully 17 00:01:09,350 --> 00:01:15,770 save you a lot of time and hopefully surprise you with what's possible on the Cisco iOS. 18 00:01:17,450 --> 00:01:20,300 In this example, I'm running a Cisco router. 19 00:01:20,480 --> 00:01:24,110 This is a traditional Cisco iOS. 20 00:01:24,530 --> 00:01:29,210 In other words, classic Cisco iOS version 15 six to TI. 21 00:01:29,360 --> 00:01:33,950 This is a viral image that's running within Genius three. 22 00:01:34,400 --> 00:01:43,130 So on this router, what I'm going to do is enable shell processing full. 23 00:01:43,700 --> 00:01:47,520 This allows me to run Linux commands directly on the Cisco iOS. 24 00:01:47,540 --> 00:01:53,720 I could also just do it this way if I only want to run it for my current terminal and not enable it 25 00:01:53,720 --> 00:01:54,920 globally on the router. 26 00:01:54,950 --> 00:01:57,470 Have a look at the series of videos. 27 00:01:57,500 --> 00:02:04,310 If you are not sure about what this command does, I've discussed it in previous videos so I won't go 28 00:02:04,310 --> 00:02:06,230 through all the options here. 29 00:02:06,950 --> 00:02:11,090 Now shell processing supports quite a few commands. 30 00:02:11,270 --> 00:02:18,350 If I tap show shell functions, I can see that cat is supported as an example. 31 00:02:18,890 --> 00:02:22,190 GREP is supported but not this option. 32 00:02:22,190 --> 00:02:25,520 Interface print interfaces that match the argument. 33 00:02:26,120 --> 00:02:37,640 I'm going to run a very basic scripture which is for x x in interface ethernet zero do echo done. 34 00:02:38,540 --> 00:02:41,390 This is a very basic script. 35 00:02:41,990 --> 00:02:44,450 Paste that directly into privilege mode. 36 00:02:45,190 --> 00:02:53,710 Notice I see the interfaces on the router similar to show IP interface brief, but I'm only looking 37 00:02:53,710 --> 00:02:55,840 at ethernet interfaces. 38 00:02:56,990 --> 00:03:00,470 So again, that's the script that I ran. 39 00:03:00,500 --> 00:03:03,680 I'll post all these scripts below this video, so don't worry. 40 00:03:03,680 --> 00:03:04,880 Trying to copy this down. 41 00:03:04,880 --> 00:03:07,250 Just get it from below the video. 42 00:03:08,090 --> 00:03:11,090 That's showing me the interfaces on the router. 43 00:03:11,210 --> 00:03:14,570 Now, that may not be that interesting. 44 00:03:14,660 --> 00:03:17,810 So let's expand the script. 45 00:03:19,010 --> 00:03:23,510 I'm going to say for x x in interface Ethernet do echo. 46 00:03:23,810 --> 00:03:26,570 Echo is one of the shell functions available. 47 00:03:27,450 --> 00:03:28,110 Notice over. 48 00:03:28,110 --> 00:03:30,600 They echo arguments to the terminal. 49 00:03:31,800 --> 00:03:35,820 So I'm going to basically echo something to the terminal. 50 00:03:36,550 --> 00:03:40,390 Based on show interface include input errors. 51 00:03:40,660 --> 00:03:48,850 So this is going to show me not just the interfaces, but it's also going to show me any input errors. 52 00:03:48,850 --> 00:03:54,040 So this line input error CRC frame overrun ignored is displayed in the output. 53 00:03:54,070 --> 00:03:57,070 So you may prefer doing that on a switch. 54 00:03:57,370 --> 00:04:02,740 So here's my switch terminal shell to enable the shell. 55 00:04:05,260 --> 00:04:06,280 Paste that in. 56 00:04:07,510 --> 00:04:15,520 I see all the interfaces on the switch and now I can see input errors, CRC overruns, etc. So I'll 57 00:04:15,520 --> 00:04:24,610 be able to see any errors on an interface by simply running a very basic two line script, if you like. 58 00:04:24,640 --> 00:04:29,650 Now if you want more details, this is available in the Cisco iOS Shell Configuration Guide. 59 00:04:30,460 --> 00:04:37,900 Again, I've covered some of this in separate videos where I talk about terminal shell versus enabling 60 00:04:38,500 --> 00:04:42,070 this globally on a device. 61 00:04:42,370 --> 00:04:47,860 But if you scroll down, they start talking about scripts that you can run. 62 00:04:48,430 --> 00:04:50,800 So very basic script is echo. 63 00:04:50,800 --> 00:04:58,720 Here is a string with x, y, z in it where x, y, z is a variable in my basic script. 64 00:05:00,220 --> 00:05:02,320 This is my variable x x. 65 00:05:03,400 --> 00:05:05,470 So that's used in multiple places. 66 00:05:08,520 --> 00:05:09,900 Scrolling down a bit further. 67 00:05:09,990 --> 00:05:15,990 We can use if statements we can use for loops. 68 00:05:16,410 --> 00:05:19,710 So let's take a very basic for loop here. 69 00:05:21,180 --> 00:05:22,860 Directly from the documentation. 70 00:05:23,070 --> 00:05:30,050 On my switch I'll paste that in four x in one, two, three, four, five echo x. 71 00:05:30,060 --> 00:05:31,260 So just print that out. 72 00:05:31,530 --> 00:05:32,390 That's what we get. 73 00:05:32,400 --> 00:05:33,630 One, two, three, four, five. 74 00:05:33,660 --> 00:05:40,200 Not very interesting, but let's do something with this by using a loop. 75 00:05:41,150 --> 00:05:42,740 With a break statement. 76 00:05:44,400 --> 00:05:47,040 So I'll copy this exactly as it is. 77 00:05:48,560 --> 00:05:55,190 And I'll paste that into switch and we get numbers one, two, three, up to ten. 78 00:05:55,580 --> 00:05:57,050 Again, not that interesting. 79 00:05:57,290 --> 00:06:05,120 But what I've done is I've taken this exact script and then I've enhanced it slightly to do something 80 00:06:05,120 --> 00:06:05,780 useful. 81 00:06:07,530 --> 00:06:10,740 So here's my script. 82 00:06:12,090 --> 00:06:19,620 I've created a function which means that it's a command that I can run multiple times rather than just 83 00:06:19,620 --> 00:06:22,080 pasting something into the CLI. 84 00:06:22,260 --> 00:06:27,810 So at the moment on the switch, if I tap show run, that doesn't work. 85 00:06:29,520 --> 00:06:32,520 It's actually trying to do a domain lookup here on that. 86 00:06:32,520 --> 00:06:38,730 So I'll speed up the video to break that notice it's doing translating show run. 87 00:06:40,110 --> 00:06:46,170 So no IP domain lookup. 88 00:06:48,830 --> 00:06:54,860 If our top show run that command doesn't work it's trying to do domain lookup on that obviously show 89 00:06:54,860 --> 00:07:03,230 run like that will do something to show space run but S-H or UN is not a valid command. 90 00:07:04,160 --> 00:07:08,630 But what I can do is paste my script in. 91 00:07:09,440 --> 00:07:12,500 So I've created this function called Show Run. 92 00:07:14,370 --> 00:07:18,630 Literally pasting that script in that I've created. 93 00:07:20,070 --> 00:07:21,720 Now if our top show run. 94 00:07:22,470 --> 00:07:26,490 It's doing a whole bunch of stuff and actually let me edit that down. 95 00:07:27,360 --> 00:07:33,420 What I've done here is create this function setting end to minus one, and while something is true, 96 00:07:33,420 --> 00:07:37,260 do something end is equal to itself plus one. 97 00:07:37,860 --> 00:07:44,880 So while end is less than or equal to three type show run interface gigabit is zero something. 98 00:07:45,360 --> 00:07:50,150 I'll get rid of the show IP route because that just confuses the output. 99 00:07:50,160 --> 00:07:52,170 So paste that back in again. 100 00:07:53,160 --> 00:07:53,970 Show run. 101 00:07:55,510 --> 00:08:01,640 What this command has done is it's running a show run interface on specific interfaces. 102 00:08:01,660 --> 00:08:05,350 Notice gigabit is zero zero gigabit or zero one. 103 00:08:05,350 --> 00:08:08,540 Gigabit is error two and gigabit is error three. 104 00:08:08,560 --> 00:08:14,350 It's also printing out this number which came from our script, that echo. 105 00:08:14,380 --> 00:08:15,610 Let's get rid of that. 106 00:08:16,210 --> 00:08:26,080 So I'm basically creating a function here that does a show run of interfaces on the switch. 107 00:08:26,080 --> 00:08:33,640 So show run first interface zero zero is then 0102, zero three and so forth. 108 00:08:33,909 --> 00:08:39,700 So it's doing a show run on each interface, but you could type any command here. 109 00:08:39,970 --> 00:08:49,150 I've just done show run, interface gigabit zero and then a number I could do show interface like that. 110 00:08:49,630 --> 00:08:55,450 So rather than show run, do a show interface on individual interfaces. 111 00:08:56,290 --> 00:09:00,820 So top that again, show run, there's the first interface. 112 00:09:01,810 --> 00:09:03,400 There's the second interface. 113 00:09:04,120 --> 00:09:05,350 Third interface. 114 00:09:06,420 --> 00:09:08,640 Fourth interface and done. 115 00:09:10,030 --> 00:09:13,120 Now there are more interfaces than that on the switch. 116 00:09:14,580 --> 00:09:18,230 A whole bunch of interfaces are available in the switch. 117 00:09:18,240 --> 00:09:25,770 But what I wanted to show you is that you can run Linux scripts directly on the Cisco iOS by simply 118 00:09:25,920 --> 00:09:33,690 enabling shell processing full, either globally on the switch or just typing terminal shell. 119 00:09:36,720 --> 00:09:42,960 This document on Cisco's website, which I'll link below, gives you more examples where you can do 120 00:09:42,960 --> 00:09:44,550 like logical tests. 121 00:09:44,940 --> 00:09:47,790 If this equals this, then echoes something. 122 00:09:48,210 --> 00:09:50,170 There's a whole bunch of options that you can do. 123 00:09:50,190 --> 00:09:52,440 This is actually one of the commands I've just shown you. 124 00:09:52,950 --> 00:09:56,550 You can actually configure interfaces if you want to. 125 00:09:57,340 --> 00:10:00,350 So as an example, set to the interface description to something. 126 00:10:01,100 --> 00:10:01,380 Okay. 127 00:10:01,400 --> 00:10:06,170 I don't want to turn this into a programming video because it'll get too long. 128 00:10:06,200 --> 00:10:14,870 I just wanted to show you some basic scripts that you may find useful like this, showing all interface 129 00:10:14,870 --> 00:10:18,590 errors, and then you can do basic or more complex scripting. 130 00:10:19,940 --> 00:10:21,840 Okay, so I hope you found this video useful. 131 00:10:21,860 --> 00:10:23,120 I hope you've learned something. 132 00:10:23,330 --> 00:10:28,670 I'll continue creating additional videos showing you options in the Cisco iOS that perhaps you don't 133 00:10:28,670 --> 00:10:29,510 know about. 134 00:10:29,600 --> 00:10:31,880 That can make you a better network engineer. 135 00:10:32,360 --> 00:10:35,600 Once again, if you don't mind, please subscribe to my YouTube channel. 136 00:10:35,600 --> 00:10:39,260 Please like this video and please click on the bell to get notifications. 137 00:10:39,290 --> 00:10:40,340 I'm David Bumble. 138 00:10:40,370 --> 00:10:43,850 I want to wish you all the very best as we vote this.