Find the interface based on MAC or IP address on Juniper Routers (JunOS)

Here are the sample steps on finding the interface where the host is connected based on IP address or MAC address on Juniper Routers.

Scenario 1: IP address is given, find which interface it is connected
IP address: 192.168.15.6

a. Find the routing entry for the IP to know where it is connected

show route <IP>

darwin@JUNIPER-re0> show route 192.168.15.6

inet.0: 3 destinations, 6 routes (3321 active, 0 holddown, 3 hidden)
+ = Active Route, – = Last Active, * = Both

192.168.15.0/26 *[Direct/0] 136w3d 20:05:05
> via irb.888

{master}
darwin@JUNIPER-re0>

Note: From the output above, we found out that is routed via VLAN 888

b. Show the arp for the interface

show arp interface <interface>

darwin@JUNIPER-re0> show arp interface irb.888
MAC Address Address Name Interface Flags
d4:44:e5:55:f6:66 192.168.15.6 192.168.15.6 irb.888 [xe-3/0/54.0] none
a1:11:b2:22:c3:33 192.168.15.7 192.168.15.7 irb.888 [xe-3/0/55.0] none

Total entries: 2

{master}
darwin@JUNIPER-re0>

Note: From the output above, we found out that the IP 192.168.15.6 mac address is d444.e555.f666 , now we need to find now where the interface it is connected.

c. Show the mac address table

show ethernet-switching table <MAC address>

darwin@JUNIPER-re0> show ethernet-switching table d4:44:e5:55:f6:66

MAC flags (S – static MAC, D – dynamic MAC, L – locally learned, P – Persistent static, C – Control MAC
SE – statistics enabled, NM – non configured MAC, R – remote PE MAC, O – ovsdb MAC)

Ethernet switching table : 2 entries, 2 learned
Routing instance : default-switch
Vlan MAC MAC Age Logical NH RTR
name address flags interface Index ID
VLAN-888 d4:44:e5:55:f6:66 D – xe-3/0/54.0 0 0

{master}
darwin@JUNIPER-re0>

Note: From the output above, we found out that mac address is mapped or learned from interface xe-3/0/54

d.  Verify the interface

show configuration interfaces <interface>

darwin@JUNIPER-re0> show configuration interfaces xe-3/0/54
description “Connection to ServerA”;
unit 0 {
family ethernet-switching {
interface-mode access;
vlan {
members VLAN-888;
}
}
}

{master}
darwin@JUNIPER-re0>

Scenario 2: MAC address is given, it is pretty straightforward to find where is being learned by what interface
MAC address: a111.b222.c333 (a1:11:b2:22:c3:33)

show ethernet-switching table <MAC address>

darwin@JUNIPER-re0> show ethernet-switching table a1:11:b2:22:c3:33

MAC flags (S – static MAC, D – dynamic MAC, L – locally learned, P – Persistent static, C – Control MAC
SE – statistics enabled, NM – non configured MAC, R – remote PE MAC, O – ovsdb MAC)

Ethernet switching table : 2 entries, 2 learned
Routing instance : default-switch
Vlan MAC MAC Age Logical NH RTR
name address flags interface Index ID
VLAN-888 a1:11:b2:22:c3:33 D – xe-3/0/55.0 0 0

{master}
darwin@JUNIPER-re0>

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *