Can Junos Show Matching Config Statement in Context Like IOS `| section`?

clijuniperjuniper-junos

Hard to describe what I'm asking.
For example, here's a section of my config, with the full hierarchy:

interfaces {
    ge-0/1/9 {
        vlan-tagging;
        unit 100 {
            description "my cool interface";
            vlan-id 100;
            family inet {
                address 192.168.66.66/25;
            }
        }
    }
}

So now I want to see what's up on the interface where I have that "66" IP. Hooray | match!
But this:

me@router> show configuration | match 66
                address 192.168.66.66/25;

… is not that useful. This:

me@router> show configuration | match 66 | display set
set interfaces ge-0/1/9 unit 100 family inet address 192.168.66.66/25

me@router> show configuration interfaces ge-0/1/9.100
description "my cool interface";
vlan-id 100;
family inet {
    address 192.168.66.66/25;
}

… is better. But what I'd really like is that whole config chunk from above, with one easy show command. Something like this:

me@router> show configuration | match 66 | display section
interfaces {
    ge-0/1/9 {
        unit 100 {
            description "my cool interface";
            vlan-id 100;
            family inet {
                address 192.168.66.66/25;
            }
        }
    }
}

I know | display section doesn't exist on Junos, but is there any way to get an output like this?

Best Answer

What you're after isn't possible in the CLI, but below are some ways that might get you more info:

First, give yourself the breadcrumbs permission (You'll need a Junos version >=12.2 for this) eg:

set system login class admin configuration-breadcrumbs
set system login class admin permissions all
set system login user <your user> class admin

show configuration

/255 or ?255 if you need to do a reverse search

Now if you back up to where your config is (clunky I know) you should get the full breadcrumbs to the interface eg:

[interfaces ge-0/1/9 unit 100]

This works better if you know what section you're looking for to start with eg: show configuration interfaces | hold (to keep the pager running even if you've got less than a page of interface config).

Alternatively show configuration | display set then /255 to find your IP, then m ge-0/1/9 to take the output and only match on the interface your IP is on. You can then subsequently clear the match term with c (to get the full configuration back) and then /255 again to find the next occurrence.