List trunk ports on Juniper Switch

Have you ever wanted to list the trunk ports on a Juniper EX switch? Unfortunately there doesn’t seem to exist a single dedicated command for this purpose. In the past I used to use the following command:

 > show ethernet-switching interfaces detail | match Trunk

but this is not working on new releases. Juniper keeps changing formats continuously. You can see if a port is trunk or not by;

>show interfaces ge-0/0/0 extensive
..
..
Flags: Is-Primary, Trunk-Mode

as you have the “Trunk-Mode” tag. However now I see that I can use configuration command as a work around to list all trunk ports. Thanks to wildcard command! Here is how I do it:

>config
#wildcard range show ge-[0-9]/0/[0-47] | display set | match trunk
set interfaces ge-1/0/8 unit 0 family ethernet-switching port-mode trunk
set interfaces ge-1/0/9 unit 0 family ethernet-switching port-mode trunk
set interfaces ge-1/0/10 unit 0 family ethernet-switching port-mode trunk
set interfaces ge-1/0/12 unit 0 family ethernet-switching port-mode trunk
set interfaces ge-1/0/14 unit 0 family ethernet-switching port-mode trunk
set interfaces ge-1/0/16 unit 0 family ethernet-switching port-mode trunk

It simply displays all FPCs from 0 to 9 and ports from 0 to 47. If you haven’t used wildcard so far, check juniper page for more details and examples.

If you know a nicer way of displaying trunk ports, please drop your comment.

About: rtoodtoo

Genco has worked for more than 10 years as a Network/Support Engineer. He is also interested in Python, Linux, Security and SD-WAN, currently lives in the Netherlands and works as a Network Support Engineer at Tesla Inc. // JNCIE-SEC #223 / RHCE / PCNSE


You have a feedback?

This site uses Akismet to reduce spam. Learn how your comment data is processed.