10-03-2013 06:17 AM
Hi
One of the commands that was very handy on the Catalyst was the "section" command. But this isn't available on the ASR9K. Apparently there is a way of doing this with egrep that someone showed me on a course, but I've forgotten and I can't get hold of the person anymore. It might help if I explain what I am trying to achieve.
We have route-policy being used in a neighbor-group. If I want to search which neighbor-group is using the policy, I'd would use something like:
show run | sec myroutepolicy
I'll post if I think of other examples.
At the very least, being able to find a few lines before or after the searched string would be great.
Thanks in advance
Solved! Go to Solution.
10-03-2013 07:29 PM
Hi Mahomed,
I'm not much sure about the egrep to filter based on section. But if your need is to find which neighbor-group a policy is attached to, there is a much simpler way. Look for the attach point.
eg;
#sh rpl route-policy V4-ADVERTISE-DEFAULT-ONLY attachpoints
BGP Attachpoint: Neighbor
Neighbor/Group type afi/safi in/out vrf name bound by
--------------------------------------------------------------------------------
TIER4-IPv4-CMTS nbr IPv4/uni out default V4-ADVERTI
This would tell you, to which all attach-points (neighbor-group) its mapped.
Regards,
Sudeep
10-03-2013 07:29 PM
Hi Mahomed,
I'm not much sure about the egrep to filter based on section. But if your need is to find which neighbor-group a policy is attached to, there is a much simpler way. Look for the attach point.
eg;
#sh rpl route-policy V4-ADVERTISE-DEFAULT-ONLY attachpoints
BGP Attachpoint: Neighbor
Neighbor/Group type afi/safi in/out vrf name bound by
--------------------------------------------------------------------------------
TIER4-IPv4-CMTS nbr IPv4/uni out default V4-ADVERTI
This would tell you, to which all attach-points (neighbor-group) its mapped.
Regards,
Sudeep
10-03-2013 08:14 PM
Hi Mahomed
Another way too find this information (in addition to the good info from Sudeep) si to look at BGP. In this example ISP-V4-PEER is my neighbor group, and this shows which neighbors are using it:
RP/0/RSP1/CPU0:asr9k#show bgp neighbor-group ISP-V4-PEER ?
configuration Show the effective configuration
inheritance Show the groups this neighbor/group can inherit config from
users Show the neighbors/groups that can inherit config from this group
RP/0/RSP1/CPU0:asr9k#show bgp neighbor-group ISP-V4-PEER users
Session: 10.0.128.73 10.0.128.71 10.0.128.69
IPv4 Unicast: 10.0.128.73 10.0.128.71 10.0.128.69
Regarding the IOS | section, we don't need the "section" in XR, just do:
show run router bgp
or
show run router bgp
etc,etc
With XR each config section stanza can be looked at without the need for "| section"
regards,
david
10-04-2013 03:38 AM
Thanks Sudeep, that's exactly what I needed to fix the immediate problem. I still would've liked to know how to view a "section" or at least lines before and after a result using egrep.
David, thanks for the info. In this case your exact command didn't help, but Sudeep's did. I completely understand about the ASR providing commands to view parts of the config or return specific info about the config (like Sudeep's example). Now don't get me wrong, I love the flexibility and the useful information that is returned. But I have a few problems with this approach:
But the info returned is great so I'll try to learn more of the commands. Thanks for your help.
10-09-2013 05:32 AM
Interesting you bring that up, I recently got this question a few times in the past few weeks, I have a functionality enhancement open for this. Follow CSCuj69066
the egrep you are asking about is show run | include Interface | utility egrep -C 3 (to get 3 surrounding lines)
but that is not working (anymore) in XR due to the egrep version it has in the qnx...
xander
10-10-2013 03:00 AM
Hi Alexander
I KNEW it was possilbe! But yes, you are right that option doesn't seem to be working anymore in 4.3. I'm glad it wasn't just me going mad. It's a pity we can't "vote" on the bug so Cisco can see how many people want it fixed or are affected.
I actually found another reason to use such a command. I searched my config for 499. I thehn get a result like this:
[code]
Thu Oct 10 10:46:07.237 BST
Building configuration...
source Bundle-Ether121.499
[code]
But now how would I find the exact bit of config? This is where the "section" or even better, the egrep command would be useful.
10-10-2013 04:53 AM
Hi Mahomed,
yup that is the usecase I have for it also. The bug voting is a nice one, let me see if we can do something with that.
It may not change overnight, but definitely something worth exploring.
regards!
xander
10-10-2013 12:57 PM
Mohamed,
Another useful way to find the section of the config where certain lines are configured or also how many places something is under. For example:
RP/0/RSP1/CPU0:ASR9006-E#sh run formal | in 0/1/0/15
Thu Oct 10 19:54:49.290 UTC
Building configuration...
interface TenGigE0/1/0/15 cdp
interface TenGigE0/1/0/15 ipv4 address 22.22.22.21 255.255.255.0
interface TenGigE0/1/0/15 shutdown
router ospf 1 area 0 interface TenGigE0/1/0/15
mpls ldp interface TenGigE0/1/0/15
RP/0/RSP1/CPU0:ASR9006-E#
Here you can see that tengig 0/1/0/15 is configured under OSPF and MPLS LDP.
Bryan
10-10-2013 11:58 PM
Hi Bryan
I almost missed the fact that the bit you were highlighting in that command was the formal keyword But after reading it a couple of times I understood (No coffee yet).
I have tested it with my search and it has indeed highlighted the correct section of the config that I would need. I'm definitely going to remember that keyword and use it more often in my searches Thanks again.
05-01-2023 10:05 AM
That was incredibly helpful. Does this put the sections into a sort of one line output? That works for me!
05-10-2023 01:54 PM
show run formal as mentioned by Bryan can be combined with | i <text> and also specific sections of the config. Lets say you wanted to look at only show router ospf but you have multiple instances. You could do show run formal router ospf | i Loopback
RP/0/RP0/CPU0:8812-A#show run formal router ospf | i Loopback
Wed May 10 20:49:38.074 UTC
router ospf 1 area 0 interface Loopback101
router ospf sv area 0 interface Loopback222
router ospf sv area 0 interface Loopback222 passive enable
router ospf 123 area 0 interface Loopback312
router ospf test area 0 interface Loopback0
router ospf mpls1 area 0 interface Loopback0
router ospf mpls1 area 0 interface Loopback0 prefix-sid index 2
router ospf mpls1 area 0 interface Loopback100
RP/0/RP0/CPU0:8812-A#
I should note that if you are using things like neighbor-groups or apply-groups you can use 'inheritance' to show the full config.
RP/0/RP0/CPU0:8812-A#show run group default_lsp_setup
Wed May 10 20:52:01.274 UTC
group default_lsp_setup
mpls traffic-eng
named-tunnels
tunnel-te '.*'
path-option 1
preference 1
computation dynamic
!
!
!
!
end-group
RP/0/RP0/CPU0:8812-A#show run mpls traffic-eng
Wed May 10 20:52:11.753 UTC
mpls traffic-eng
interface Bundle-Ether1013
!
signalling advertise explicit-null
named-tunnels
tunnel-te TU
autoroute announce
metric 498
!
destination 10.140.199.58
!
!
!
RP/0/RP0/CPU0:8812-A#show run mpls traffic-eng inheritance
Wed May 10 20:52:16.544 UTC
mpls traffic-eng
interface Bundle-Ether1013
!
signalling advertise explicit-null
named-tunnels
tunnel-te TU
path-option 1
preference 1
computation dynamic
!
autoroute announce
metric 498
!
destination 10.140.199.58
!
!
!
RP/0/RP0/CPU0:8812-A#show run formal mpls traffic-eng inheritance
Wed May 10 20:53:25.609 UTC
mpls traffic-eng
mpls traffic-eng interface Bundle-Ether1013
mpls traffic-eng signalling advertise explicit-null
mpls traffic-eng named-tunnels
mpls traffic-eng named-tunnels tunnel-te TU
mpls traffic-eng named-tunnels tunnel-te TU path-option 1
mpls traffic-eng named-tunnels tunnel-te TU path-option 1 preference 1
mpls traffic-eng named-tunnels tunnel-te TU path-option 1 computation dynamic
mpls traffic-eng named-tunnels tunnel-te TU autoroute announce
mpls traffic-eng named-tunnels tunnel-te TU autoroute announce metric 498
mpls traffic-eng named-tunnels tunnel-te TU destination 10.140.199.58
RP/0/RP0/CPU0:8812-A#show run formal mpls traffic-eng
Wed May 10 20:53:31.650 UTC
mpls traffic-eng
mpls traffic-eng interface Bundle-Ether1013
mpls traffic-eng signalling advertise explicit-null
mpls traffic-eng named-tunnels
mpls traffic-eng named-tunnels tunnel-te TU
mpls traffic-eng named-tunnels tunnel-te TU autoroute announce
mpls traffic-eng named-tunnels tunnel-te TU autoroute announce metric 498
mpls traffic-eng named-tunnels tunnel-te TU destination 10.140.199.58
Sam
07-31-2014 01:07 AM
Hi Xander,
- I'm missing exactly the same functionality with egrep (-A, -B,..). It's not just about config, it would be very helpful with various sh commands.
Any news on that in the meantime?
thx
thomas
08-12-2014 09:49 AM
Still not working in 5.2.0 either :( What do we have to do to get this bug noticed?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide