cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
898
Views
0
Helpful
6
Replies

Regex or grep to see IP prefix

networkinggeek
Level 1
Level 1

It is quiet simple question, but I am sure would be real helpful, so I have a bgp neighbors with this prefix x.x.x.*

 

I am trying to do this, so that I get current status of all neighbors, but * or [] does not work. Anyone who can help here.

 

sh ip bgp neighbors X.X.X.* | in Des|state

% Invalid input detected at '^' marker.

or 

sh bgp neighbors X.X.X.* | in Des|state

 

--

Sal

1 Accepted Solution

Accepted Solutions

Hello,

 

sh ip bgp neighbors | include BGP neighbor is 192.168.1[0-9]| BGP state =

View solution in original post

6 Replies 6

Hello,

 

which output are you after, what do you mean by 'status' ?

 

sh ip bgp neighbors | include BGP neighbor is | BGP state =

 

results in

 

BGP neighbor is 192.168.12.2, remote AS 2, external link
BGP state = Established, up for 00:05:25
BGP neighbor is 192.168.13.3, remote AS 3, external link
BGP state = Established, up for 00:03:49

So I want to look at all BGP neighbors in that prefix, say I have multiple neighbors in this prefix 192.168.1.x and I would like to check if they are all established or active. I want to know if we can use regex or something similar like this below?

 

sh ip bgp neighbors 192.168.1.* | in Des|state 

 

Which should show me all neighbors in that IP range and there current BGP state

Hello,

 

sh ip bgp neighbors | include BGP neighbor is 192.168.1[0-9]| BGP state =

Sweet :)

Not perfect as you have seen, since all the BGP state = lines are listed even when the IP address doesn't match. I haven't figured out how to filter those out...

Yes I have noticed it, it shows states for non-matching results as well. but pretty close to what I wanted to see, Let me know if you were able to refine it more :) 

 

regex is quiet handy once you get good grip of it. So I am trying to learn and slowly apply. 

Review Cisco Networking for a $25 gift card