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.
I think you still can do it similar to as you did in non-ELS :
@ex2300-c-12p> show ethernet-switching interface |match ” tagged” |match .e-
ge-0/0/11.0 16384 DN tagged
ge-0/1/0.0 16384 tagged
OR
If you prefer to have the VLANs printed that is included in the trunk as well:
@ex2300-c-12p> show ethernet-switching interface |match ” tagged”
ge-0/0/11.0 16384 DN tagged
default 1 16384 Discarding tagged
TEST 10 16384 Discarding tagged
SERVER 20 16384 Discarding tagged
REJECT 99 16384 Discarding tagged
ge-0/1/0.0 16384 tagged
default 1 16384 Forwarding tagged
TEST 10 16384 Forwarding tagged
SERVER 20 16384 Forwarding tagged
REJECT 99 16384 Forwarding tagged
N.B!
(I have tried to rectify the output with spaces)