6

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?

  • 4
    how about show configuration | find 66 (and then possibly scroll a few lines back)? – Teun Vink Mar 21 '18 at 21:19
  • @TeunVink Oh! I didn't know you could scroll. That's a good option. It's not everything I'm looking for, because I'd really like that kind of output for multiple matches. (Just tried to keep the question simple.) – Jacktose Mar 21 '18 at 21:22
  • 5
    You do know that / <enter> brings you to the next search result? I guess you could do some tricks with slax if you feel brave enough, or code something using netconf, pyez, if you really want what you describe. I don' think it's possible the way you describe it without any additional work. – Teun Vink Mar 21 '18 at 21:52
  • Yeah, thanks. I was just hoping to get a nice concise output in one go, without a lot of cutting and pasting to get the relevant parts. I guess I'll have to script it if I really care. – Jacktose Mar 21 '18 at 22:15
  • Personally, I would rely on a database which would be used to generate the config and do the searching there. Logging into a router is something only scripts should do ;-) – Teun Vink Mar 21 '18 at 22:17
4

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.

0

With the section in mind / your search in context, you can add another pipe with "display set". For exapmle, if you want to find "http" in the config and you want to know under what section it lives in the hierarchy, use the following command:

show configuration | match http | display set

set security zones security-zone trust interfaces vlan.0 host-inbound-traffic system-services http

set security zones security-zone trust interfaces vlan.0 host-inbound-traffic system-services https
  • 3
    You might want to change “grep” to “match” as it is in Junos – Benjamin Dale Apr 12 at 13:07
  • @BenjaminDale | grep actually works in Junos. At least, the versions I'm using. – Jacktose Apr 12 at 22:31
  • @DeanG You'll see that I've addressed this (combining match & display set) in my question, as an inferior option. – Jacktose Apr 12 at 22:32
  • 1
    My apologies @P1h3r1e3d13 - you learn something new every day : ) – Benjamin Dale Apr 13 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.