1 00:00:00,000 --> 00:00:03,968 [AUDIO LOGO] 2 00:00:03,968 --> 00:00:07,950 3 00:00:07,950 --> 00:00:12,600 So again, it's not always appropriate to filter routes 4 00:00:12,600 --> 00:00:14,250 based on the prefix. 5 00:00:14,250 --> 00:00:18,540 Sometimes we may not know what the prefixes are. 6 00:00:18,540 --> 00:00:21,000 For example, if we wanted to make sure 7 00:00:21,000 --> 00:00:26,130 that a customer was only advertising their own prefixes, 8 00:00:26,130 --> 00:00:29,910 well, we may or may not know what those prefixes actually 9 00:00:29,910 --> 00:00:30,660 are. 10 00:00:30,660 --> 00:00:34,320 But to make sure that it's their prefixes, what we can do 11 00:00:34,320 --> 00:00:37,860 is filter on the AS path and make sure 12 00:00:37,860 --> 00:00:40,800 that those routes are coming just from their AS. 13 00:00:40,800 --> 00:00:43,680 So in a lot of cases, it's useful 14 00:00:43,680 --> 00:00:46,890 not to filter based on the prefix but rather 15 00:00:46,890 --> 00:00:49,390 some element of the AS path. 16 00:00:49,390 --> 00:00:51,270 Now, of course, that's going to vary 17 00:00:51,270 --> 00:00:53,470 in a bunch of different situations. 18 00:00:53,470 --> 00:00:55,530 But what we want to do is make sure 19 00:00:55,530 --> 00:00:59,130 that we know how to filter on the AS path effectively. 20 00:00:59,130 --> 00:01:02,070 The way we do that is by using something 21 00:01:02,070 --> 00:01:06,850 called regular expressions in an AS path filter list. 22 00:01:06,850 --> 00:01:09,960 So let's go ahead and jump in and do a quick review 23 00:01:09,960 --> 00:01:11,850 of regular expressions. 24 00:01:11,850 --> 00:01:15,300 If this is your first time seeing regular expressions, 25 00:01:15,300 --> 00:01:17,800 it may be a little bit overwhelming at first. 26 00:01:17,800 --> 00:01:19,890 However, with a little bit of practice, 27 00:01:19,890 --> 00:01:21,850 these really aren't that bad. 28 00:01:21,850 --> 00:01:24,330 So let's go ahead and jump in and look 29 00:01:24,330 --> 00:01:27,180 at the regular expressions and particularly some 30 00:01:27,180 --> 00:01:29,520 of the special characters that we can use 31 00:01:29,520 --> 00:01:31,440 with those regular expressions. 32 00:01:31,440 --> 00:01:37,410 Then we'll jump into the command line and see this in action. 33 00:01:37,410 --> 00:01:40,970 So as we stated, the way that we do this is using something 34 00:01:40,970 --> 00:01:42,890 called AS path filters. 35 00:01:42,890 --> 00:01:49,160 And those AS path filters use Regular Expressions, or RegEx, 36 00:01:49,160 --> 00:01:54,230 as a method to filter or match on the text string, 37 00:01:54,230 --> 00:01:59,100 or, in the case of the AS path, a numeric string. 38 00:01:59,100 --> 00:02:01,250 Now, just for a little bit of background here, 39 00:02:01,250 --> 00:02:05,120 RegEx does have its basis in Unix. 40 00:02:05,120 --> 00:02:09,470 And the Cisco implementation is actually a subset 41 00:02:09,470 --> 00:02:13,030 of that Unix implementation. 42 00:02:13,030 --> 00:02:14,890 The main reason I'm bringing this up 43 00:02:14,890 --> 00:02:18,050 is if you don't know regular expressions very well 44 00:02:18,050 --> 00:02:21,220 and you decide to go research this a bit more on your own, 45 00:02:21,220 --> 00:02:24,040 as you are searching for information on the internet, 46 00:02:24,040 --> 00:02:28,030 make sure you're looking at Cisco regular expressions 47 00:02:28,030 --> 00:02:31,370 because, again, their implementation is a subset. 48 00:02:31,370 --> 00:02:34,330 So if you just do regular expressions in general, 49 00:02:34,330 --> 00:02:36,100 you might get some information that 50 00:02:36,100 --> 00:02:40,240 applies to a Unix-based system but not IOS. 51 00:02:40,240 --> 00:02:42,040 So just be careful that we're looking 52 00:02:42,040 --> 00:02:45,590 at the right information when it comes to regular expressions. 53 00:02:45,590 --> 00:02:49,060 Now, regular expressions are made up of elements. 54 00:02:49,060 --> 00:02:52,030 And those elements are called atoms. 55 00:02:52,030 --> 00:02:55,150 This will become more important and more relevant 56 00:02:55,150 --> 00:02:57,830 as we go through a few examples here. 57 00:02:57,830 --> 00:02:59,890 But before we jump into our examples, 58 00:02:59,890 --> 00:03:02,440 let's review some of the special characters 59 00:03:02,440 --> 00:03:06,230 that we have available with regular expressions. 60 00:03:06,230 --> 00:03:08,750 So first up is just a single dot. 61 00:03:08,750 --> 00:03:14,020 This is a wildcard that indicates any single character. 62 00:03:14,020 --> 00:03:19,840 You have an underscore, which indicates any space, tab, 63 00:03:19,840 --> 00:03:23,170 beginning, or end of line. 64 00:03:23,170 --> 00:03:26,980 We have the pipe, which indicates an OR. 65 00:03:26,980 --> 00:03:30,340 We have the caret, which indicates 66 00:03:30,340 --> 00:03:34,160 the beginning of string, the dollar sign, 67 00:03:34,160 --> 00:03:36,880 which is, of course, the end of the string, 68 00:03:36,880 --> 00:03:40,660 parentheses that make up a grouping. 69 00:03:40,660 --> 00:03:43,460 We can use brackets to create a set. 70 00:03:43,460 --> 00:03:46,510 And then we have some other wildcard operators. 71 00:03:46,510 --> 00:03:55,250 The question mark means zero or one of the preceding atom. 72 00:03:55,250 --> 00:03:57,860 And this is where the atoms become important. 73 00:03:57,860 --> 00:04:01,010 So it relates to the character in front of it. 74 00:04:01,010 --> 00:04:04,300 Same with the asterisk, or the star. 75 00:04:04,300 --> 00:04:07,570 This is zero or more. 76 00:04:07,570 --> 00:04:11,230 The plus indicates one or more. 77 00:04:11,230 --> 00:04:13,750 And again, all three of these are 78 00:04:13,750 --> 00:04:17,240 related to that atom that precedes them. 79 00:04:17,240 --> 00:04:19,390 So all of them are operating on the atom 80 00:04:19,390 --> 00:04:21,380 directly in front of them. 81 00:04:21,380 --> 00:04:22,810 Another interesting character here 82 00:04:22,810 --> 00:04:27,910 is the backslash, which actually escapes the meaning 83 00:04:27,910 --> 00:04:30,490 of the following character. 84 00:04:30,490 --> 00:04:33,190 So just as an example, if you wanted 85 00:04:33,190 --> 00:04:36,590 to match on an actual question mark, 86 00:04:36,590 --> 00:04:38,890 well, you can't really do that, because again, 87 00:04:38,890 --> 00:04:42,010 the question mark has a special meaning over here. 88 00:04:42,010 --> 00:04:44,290 It means zero or one. 89 00:04:44,290 --> 00:04:47,260 So if you wanted to literally match on the question mark 90 00:04:47,260 --> 00:04:51,730 itself, you would have to say backslash question mark so 91 00:04:51,730 --> 00:04:54,790 that it escapes the normal meaning of the question mark, 92 00:04:54,790 --> 00:04:56,740 meaning zero or one. 93 00:04:56,740 --> 00:04:59,410 So if we're escaping the normal meaning, 94 00:04:59,410 --> 00:05:01,300 it uses the alternate meaning, which 95 00:05:01,300 --> 00:05:02,740 in the case of the question mark, 96 00:05:02,740 --> 00:05:05,660 would be a literal question mark. 97 00:05:05,660 --> 00:05:08,440 The best way to do this is to jump in and take 98 00:05:08,440 --> 00:05:11,020 a look at some common implementations 99 00:05:11,020 --> 00:05:12,450 of regular expressions. 100 00:05:12,450 --> 00:05:14,200 And then we'll jump on to the command line 101 00:05:14,200 --> 00:05:16,760 and get an idea on how these work. 102 00:05:16,760 --> 00:05:19,880 So let's take a look at some popular examples here. 103 00:05:19,880 --> 00:05:23,210 First, we have the dot asterisk. 104 00:05:23,210 --> 00:05:28,030 This is zero or more instances of the character in front. 105 00:05:28,030 --> 00:05:30,640 And the character or atom in front 106 00:05:30,640 --> 00:05:33,390 is any character because it's a dot. 107 00:05:33,390 --> 00:05:37,450 So what this actually means is any. 108 00:05:37,450 --> 00:05:40,967 This is the AS path equivalent of any any, 109 00:05:40,967 --> 00:05:43,312 like we would put in an ACL. 110 00:05:43,312 --> 00:05:44,770 Here we have an example where we're 111 00:05:44,770 --> 00:05:49,450 saying that the line has to begin with 100. 112 00:05:49,450 --> 00:05:52,300 And then it has to be followed by a space 113 00:05:52,300 --> 00:05:55,340 or the end of the line. 114 00:05:55,340 --> 00:05:58,600 So in this case, we would say that this is any route coming 115 00:05:58,600 --> 00:06:01,420 from our neighbor AS 100. 116 00:06:01,420 --> 00:06:03,670 Sort of the opposite of this is we're 117 00:06:03,670 --> 00:06:08,650 saying there has to be a space first, followed by the 100. 118 00:06:08,650 --> 00:06:11,480 And this has to be at the end of the string. 119 00:06:11,480 --> 00:06:16,420 So this would be any route originating from AS 100. 120 00:06:16,420 --> 00:06:18,430 Here we're not specifying the beginning 121 00:06:18,430 --> 00:06:19,910 or the end of the line. 122 00:06:19,910 --> 00:06:22,580 We're just saying there has to be a space. 123 00:06:22,580 --> 00:06:26,350 So this would be any route originating from 124 00:06:26,350 --> 00:06:31,120 or passing through or coming from our neighbor AS 100. 125 00:06:31,120 --> 00:06:36,130 We're simply saying that 100 has to be in the AS path somewhere, 126 00:06:36,130 --> 00:06:38,240 not the beginning, not the end. 127 00:06:38,240 --> 00:06:39,550 But it could be there. 128 00:06:39,550 --> 00:06:42,700 But it has to be in the AS path. 129 00:06:42,700 --> 00:06:45,460 Here we're specifying the beginning 130 00:06:45,460 --> 00:06:50,300 and the end of the string with 100 between them. 131 00:06:50,300 --> 00:06:52,090 This means that the route would have 132 00:06:52,090 --> 00:06:57,400 to actually be originating from and be a neighbor of AS 100. 133 00:06:57,400 --> 00:07:02,200 So AS 100 would have to be alone in the AS path. 134 00:07:02,200 --> 00:07:07,990 Another common example is to say just beginning and end. 135 00:07:07,990 --> 00:07:13,160 If we say just beginning or end, this would be an empty string. 136 00:07:13,160 --> 00:07:16,790 This is most commonly used to filter your own routes 137 00:07:16,790 --> 00:07:21,320 going out because your own routes coming from your AS 138 00:07:21,320 --> 00:07:23,780 would have nothing in the AS path, 139 00:07:23,780 --> 00:07:25,970 because they're being originated. 140 00:07:25,970 --> 00:07:28,910 And then we can get a little tricky with an AS 141 00:07:28,910 --> 00:07:31,046 path such as this. 142 00:07:31,046 --> 00:07:34,310 This would match on any AS number, 143 00:07:34,310 --> 00:07:35,990 because we're saying that it has to be 144 00:07:35,990 --> 00:07:41,960 the beginning of the string and the end of the string with zero 145 00:07:41,960 --> 00:07:46,070 or more instances of this set. 146 00:07:46,070 --> 00:07:50,810 And this set is any value zero through nine. 147 00:07:50,810 --> 00:07:55,550 So just as some examples, this would match on 37. 148 00:07:55,550 --> 00:07:57,440 This would match on 91. 149 00:07:57,440 --> 00:08:01,370 This would match on 3283. 150 00:08:01,370 --> 00:08:05,750 It'll literally match on anything because all of these 151 00:08:05,750 --> 00:08:08,720 are single instances of the number being 152 00:08:08,720 --> 00:08:11,780 repeated zero or more times. 153 00:08:11,780 --> 00:08:15,690 Now, there's no allocation here for a space. 154 00:08:15,690 --> 00:08:18,410 So it would be a single AS number. 155 00:08:18,410 --> 00:08:21,090 These numbers I put are individual examples. 156 00:08:21,090 --> 00:08:23,840 This is not an example of a single AS path. 157 00:08:23,840 --> 00:08:26,660 It would be just one AS. 158 00:08:26,660 --> 00:08:32,000 We can get a little fancier and allow one AS number to repeat. 159 00:08:32,000 --> 00:08:35,340 So if you look here, what we're doing is we're allowing, 160 00:08:35,340 --> 00:08:37,970 again, beginning and end of string. 161 00:08:37,970 --> 00:08:42,390 Then we're once again matching on any AS number. 162 00:08:42,390 --> 00:08:46,320 So it's one or more digits of any number. 163 00:08:46,320 --> 00:08:48,920 So it's any AS number. 164 00:08:48,920 --> 00:08:52,950 And then since we put this in parentheses, 165 00:08:52,950 --> 00:08:56,660 it actually stores this value into memory. 166 00:08:56,660 --> 00:09:02,360 We can then recall that memory by using a backslash 1. 167 00:09:02,360 --> 00:09:04,740 That's what this section right here is doing. 168 00:09:04,740 --> 00:09:08,870 So we're accounting for a space between the AS numbers. 169 00:09:08,870 --> 00:09:13,490 And then we're saying that that same AS number can repeat zero 170 00:09:13,490 --> 00:09:15,330 or more times. 171 00:09:15,330 --> 00:09:21,770 So as an example, this would match on, say, 93. 172 00:09:21,770 --> 00:09:28,520 It would also match on 93 93 93-- 173 00:09:28,520 --> 00:09:33,080 so any single number repeating more than one 174 00:09:33,080 --> 00:09:35,330 time or not repeating at all. 175 00:09:35,330 --> 00:09:38,870 That's fine too, because again, this asterisk right here means 176 00:09:38,870 --> 00:09:40,550 zero or more. 177 00:09:40,550 --> 00:09:44,390 And it's acting on this atom right in front of it. 178 00:09:44,390 --> 00:09:46,510 So yes, based on all these little arrows 179 00:09:46,510 --> 00:09:49,910 I drew everywhere, this gets a little more complicated. 180 00:09:49,910 --> 00:09:52,460 Take a moment, if you need to, to follow it through. 181 00:09:52,460 --> 00:09:56,620 But the end result is that we're letting our customers send us 182 00:09:56,620 --> 00:10:01,810 any routes they want as long as it has their AS number on it. 183 00:10:01,810 --> 00:10:05,920 And we're allowing them to do AS path prepending 184 00:10:05,920 --> 00:10:08,650 as long as they're prepending their own AS 185 00:10:08,650 --> 00:10:10,300 number numerous times. 186 00:10:10,300 --> 00:10:13,210 So this is actually a fairly common regular expression 187 00:10:13,210 --> 00:10:17,390 to use to filter routes coming from customers. 188 00:10:17,390 --> 00:10:20,260 So now that we have a decent idea of how these work, which 189 00:10:20,260 --> 00:10:22,900 is actually the tricky part, let's 190 00:10:22,900 --> 00:10:25,030 take a look at our topology real quick, 191 00:10:25,030 --> 00:10:28,090 then jump into the command line, and actually see 192 00:10:28,090 --> 00:10:33,430 these in action on both IOS XR and IOS XE. 193 00:10:33,430 --> 00:10:35,950 So since we've already been doing some filtering here 194 00:10:35,950 --> 00:10:38,260 throughout this skill already, let's 195 00:10:38,260 --> 00:10:41,830 go ahead and continue with our attack on router 9 196 00:10:41,830 --> 00:10:43,990 as our target for our filtering. 197 00:10:43,990 --> 00:10:47,350 And then for IOS XR, we'll pick on somebody 198 00:10:47,350 --> 00:10:50,110 who's not really in the forwarding path for anything. 199 00:10:50,110 --> 00:10:52,390 We'll just pick on router 4 down here 200 00:10:52,390 --> 00:10:55,340 and do some AS path filtering here as well. 201 00:10:55,340 --> 00:10:57,040 So let's jump into the command line. 202 00:10:57,040 --> 00:11:00,420 And we'll start on router 9. 203 00:11:00,420 --> 00:11:04,560 So let's begin with just a standard show ip bgp. 204 00:11:04,560 --> 00:11:07,140 Here we see all of the updates currently being 205 00:11:07,140 --> 00:11:09,210 learned on router 9. 206 00:11:09,210 --> 00:11:12,780 And we can actually use regular expressions 207 00:11:12,780 --> 00:11:17,470 and use this as a learning tool to filter this output. 208 00:11:17,470 --> 00:11:21,690 So what we can do is we can repeat our show ip bgp, 209 00:11:21,690 --> 00:11:25,140 add RegEx to it, and then we can filter 210 00:11:25,140 --> 00:11:27,520 using a regular expression. 211 00:11:27,520 --> 00:11:29,040 So for example, we could say, show 212 00:11:29,040 --> 00:11:31,810 me anything with a 223 in it. 213 00:11:31,810 --> 00:11:33,690 Notice it now filters the output. 214 00:11:33,690 --> 00:11:38,970 And each of these has a 223 somewhere in the output. 215 00:11:38,970 --> 00:11:41,730 Now, it may not be by itself. 216 00:11:41,730 --> 00:11:46,580 Notice how this AS path is 2232. 217 00:11:46,580 --> 00:11:49,470 So it's not 223 by itself. 218 00:11:49,470 --> 00:11:53,090 And this is because we put no delimiters around the number. 219 00:11:53,090 --> 00:11:55,220 If we wanted to see 223 by itself, 220 00:11:55,220 --> 00:11:59,610 we would have to put an underscore before and after it. 221 00:11:59,610 --> 00:12:01,880 Then it would be just the entries 222 00:12:01,880 --> 00:12:05,420 that have a 223 by themselves. 223 00:12:05,420 --> 00:12:07,790 Other things we could do, show me 224 00:12:07,790 --> 00:12:13,000 anything that has an AS that's four digits. 225 00:12:13,000 --> 00:12:17,690 Or show me anything that has an AS that's five digits. 226 00:12:17,690 --> 00:12:21,100 So we can use the dots to indicate how many characters we 227 00:12:21,100 --> 00:12:22,480 want to see. 228 00:12:22,480 --> 00:12:25,300 Now, technically, we could do something like this. 229 00:12:25,300 --> 00:12:29,170 But that's going to be anything in the entire table 230 00:12:29,170 --> 00:12:30,970 because that's a dot asterisk. 231 00:12:30,970 --> 00:12:33,050 And that's going to be, of course, anything. 232 00:12:33,050 --> 00:12:36,230 So that one wouldn't be all that useful. 233 00:12:36,230 --> 00:12:38,890 But something that might be a little more practical, 234 00:12:38,890 --> 00:12:40,720 how about if I said show me anything-- 235 00:12:40,720 --> 00:12:42,670 and we'll use a set for this-- 236 00:12:42,670 --> 00:12:49,250 that has a 5 or a 7 at the end of the number? 237 00:12:49,250 --> 00:12:53,530 So now this is only showing me things that end in a 5 or 7. 238 00:12:53,530 --> 00:12:55,840 Remember, in this case, the dollar sign 239 00:12:55,840 --> 00:13:02,200 was acting on the set, the atom, of either a 5 or a 7. 240 00:13:02,200 --> 00:13:04,570 So these are just some examples of how 241 00:13:04,570 --> 00:13:09,070 we can filter this output using regular expressions. 242 00:13:09,070 --> 00:13:11,810 And just two things about this. 243 00:13:11,810 --> 00:13:14,270 Number one, as I sort of said at the beginning, 244 00:13:14,270 --> 00:13:17,620 this is a good way to practice your regular expressions. 245 00:13:17,620 --> 00:13:19,660 Get a nice BGP table. 246 00:13:19,660 --> 00:13:21,400 And do some practice filtering. 247 00:13:21,400 --> 00:13:23,240 And look at the results. 248 00:13:23,240 --> 00:13:27,550 This can also be very practical for real-world use. 249 00:13:27,550 --> 00:13:30,070 I filter with this all the time. 250 00:13:30,070 --> 00:13:33,610 And I even have scripts set up for customers 251 00:13:33,610 --> 00:13:36,790 that can look at certain outputs based on what they 252 00:13:36,790 --> 00:13:38,720 want to see from the AS path. 253 00:13:38,720 --> 00:13:41,410 So you can use this either just for practice 254 00:13:41,410 --> 00:13:45,410 or for real-world use for filtering the BGP table. 255 00:13:45,410 --> 00:13:48,460 Now we're going to use it, of course, to actually filter 256 00:13:48,460 --> 00:13:50,410 the routes that we're learning. 257 00:13:50,410 --> 00:13:52,870 So to do this, we have to write something called 258 00:13:52,870 --> 00:13:57,370 an ip as-path access-list. 259 00:13:57,370 --> 00:14:00,670 One interesting thing here on IOS XE 260 00:14:00,670 --> 00:14:04,930 is these are only supported as numbers, at least 261 00:14:04,930 --> 00:14:06,260 in the current code. 262 00:14:06,260 --> 00:14:08,155 Now, again, it's been that way for a while. 263 00:14:08,155 --> 00:14:10,630 I'm not sure if they're ever going to change it. 264 00:14:10,630 --> 00:14:13,780 But this is one place where we don't have the opportunity 265 00:14:13,780 --> 00:14:15,040 to use names. 266 00:14:15,040 --> 00:14:19,270 So we'll just say ip as-path access-list 1. 267 00:14:19,270 --> 00:14:23,410 And let's just do something like denying anything 268 00:14:23,410 --> 00:14:25,730 that ends in an odd number. 269 00:14:25,730 --> 00:14:27,520 So we'll make a set. 270 00:14:27,520 --> 00:14:35,420 We'll say 13579-- so anything with those digits at the end. 271 00:14:35,420 --> 00:14:37,330 So that will deny any of our routes 272 00:14:37,330 --> 00:14:40,670 where the AS ends in an odd number. 273 00:14:40,670 --> 00:14:44,200 Then, of course, what we need to do is permit everything else. 274 00:14:44,200 --> 00:14:45,700 Remember that's the dot asterisk, 275 00:14:45,700 --> 00:14:47,890 the equivalent of the any. 276 00:14:47,890 --> 00:14:50,030 And then we simply apply it. 277 00:14:50,030 --> 00:14:52,510 So I'll go into router BGP 300. 278 00:14:52,510 --> 00:14:55,210 And we'll apply this towards router 1. 279 00:14:55,210 --> 00:14:57,460 We apply it with the filter-list command. 280 00:14:57,460 --> 00:14:59,470 And we'll do it inbound. 281 00:14:59,470 --> 00:15:01,450 We'll clear that neighborship. 282 00:15:01,450 --> 00:15:04,820 And then we'll do our show ip bgp again. 283 00:15:04,820 --> 00:15:06,940 What we're looking for, in this case, 284 00:15:06,940 --> 00:15:10,180 is anything that ends in an odd number. 285 00:15:10,180 --> 00:15:13,720 We can see that that's these entries here at the bottom. 286 00:15:13,720 --> 00:15:16,430 They only have a single path. 287 00:15:16,430 --> 00:15:19,360 Notice that the paths that we didn't filter out 288 00:15:19,360 --> 00:15:23,650 in previous demonstrations have multiple paths. 289 00:15:23,650 --> 00:15:26,830 But these last two, where we end in an odd number, 290 00:15:26,830 --> 00:15:29,950 are now only being learned from router 2. 291 00:15:29,950 --> 00:15:33,910 We have filtered out the extra path through router 1. 292 00:15:33,910 --> 00:15:36,550 So now that we've seen it working on IOS XE, 293 00:15:36,550 --> 00:15:40,720 let's jump over to router 4 and look at IOS XR. 294 00:15:40,720 --> 00:15:44,140 So again, let's start with the show ip bgp. 295 00:15:44,140 --> 00:15:47,530 Now, notice we have a lot more routes here that end 296 00:15:47,530 --> 00:15:51,190 in an odd number, because we have a whole ton of them that 297 00:15:51,190 --> 00:15:54,130 are coming from 65001-- 298 00:15:54,130 --> 00:15:56,080 of course, 1 being an odd number. 299 00:15:56,080 --> 00:15:58,960 We're going to lose a lot more paths here. 300 00:15:58,960 --> 00:16:00,920 But we're going to do the same thing. 301 00:16:00,920 --> 00:16:03,670 And that's OK because this is just a lab. 302 00:16:03,670 --> 00:16:07,030 So what we're going to need on IOS XR 303 00:16:07,030 --> 00:16:09,850 is we'll use what's called an as-path-set. 304 00:16:09,850 --> 00:16:13,690 So we'll just call this APS for AS Path Set. 305 00:16:13,690 --> 00:16:16,930 And then we'll call it _ODD because we're going to match 306 00:16:16,930 --> 00:16:18,730 on the odd numbers. 307 00:16:18,730 --> 00:16:20,320 Now, what we're going to tell it here 308 00:16:20,320 --> 00:16:24,700 is that we're going to use an ios-regex. 309 00:16:24,700 --> 00:16:27,940 And that RegEx we put in single quotes here. 310 00:16:27,940 --> 00:16:31,510 But it's going to be the same overall RegEx-- 311 00:16:31,510 --> 00:16:33,230 odd number at the end. 312 00:16:33,230 --> 00:16:36,220 And then we end it with another single quote. 313 00:16:36,220 --> 00:16:38,360 And we do an end-set since that's the only thing 314 00:16:38,360 --> 00:16:39,790 we're putting in here. 315 00:16:39,790 --> 00:16:41,870 We run our route-policy. 316 00:16:41,870 --> 00:16:45,800 We'll call this RP_BGP_FILTER. 317 00:16:45,800 --> 00:16:54,520 And of course, this is going to say if as-path is in APS_ODD, 318 00:16:54,520 --> 00:16:57,250 then we're going to drop it because that's 319 00:16:57,250 --> 00:17:00,190 what we're trying to do is filter these routes out, 320 00:17:00,190 --> 00:17:01,960 else we'll pass. 321 00:17:01,960 --> 00:17:06,130 We'll end our if statement and our policy. 322 00:17:06,130 --> 00:17:08,079 Go into BGP. 323 00:17:08,079 --> 00:17:10,250 And here we'll just do it from our route reflectors. 324 00:17:10,250 --> 00:17:11,865 This is a route reflector environment. 325 00:17:11,865 --> 00:17:13,240 So we just have to go into router 326 00:17:13,240 --> 00:17:17,890 1 for the address-family ipv4 unicast. 327 00:17:17,890 --> 00:17:21,030 And we'll apply our route policy. 328 00:17:21,030 --> 00:17:24,829 We'll do the same thing for router 2. 329 00:17:24,829 --> 00:17:26,930 Commit all of our changes. 330 00:17:26,930 --> 00:17:28,908 And exit configuration. 331 00:17:28,908 --> 00:17:31,200 Now, again, we're going to have a lot less routes here. 332 00:17:31,200 --> 00:17:33,980 But if we do a show ip bgp, we can 333 00:17:33,980 --> 00:17:37,880 see that a large quantity of our routes, as expected, are gone. 334 00:17:37,880 --> 00:17:40,650 But this is exactly what we were looking for it to do. 335 00:17:40,650 --> 00:17:44,020 So we can see that it's working. 336 00:17:44,020 --> 00:17:49,060 In this video, we saw how to use AS path filtering 337 00:17:49,060 --> 00:17:54,310 to filter routes out of BGP using elements of the AS path 338 00:17:54,310 --> 00:17:58,180 that we match on using regular expressions. 339 00:17:58,180 --> 00:18:01,690 Keep in mind that Cisco's implementation of RegEx 340 00:18:01,690 --> 00:18:05,260 is a subset of the Unix implementation. 341 00:18:05,260 --> 00:18:07,930 But we went over a lot of the major characters 342 00:18:07,930 --> 00:18:11,990 that we have available that we can use on the Cisco platforms. 343 00:18:11,990 --> 00:18:15,430 Now, sometimes we might want to filter out routes 344 00:18:15,430 --> 00:18:18,820 that our customers actually ask us to filter. 345 00:18:18,820 --> 00:18:21,190 And for that, we have a feature that we 346 00:18:21,190 --> 00:18:24,490 can do called remote-triggered black hole filtering. 347 00:18:24,490 --> 00:18:27,470 And that's exactly what we're going to be going over next. 348 00:18:27,470 --> 00:18:30,670 Until then, I hope this has been informative for you, 349 00:18:30,670 --> 00:18:33,750 and I'd like to thank you for viewing. 350 00:18:33,750 --> 00:18:37,000