{"id":1262,"date":"2018-08-14T14:41:03","date_gmt":"2018-08-14T07:41:03","guid":{"rendered":"https:\/\/lagonet.vn\/?p=1262"},"modified":"2018-08-14T14:41:03","modified_gmt":"2018-08-14T07:41:03","slug":"cisco-trace-mac-or-ip-addresses-to-switch-ports","status":"publish","type":"post","link":"https:\/\/kb.lagonet.vn\/?p=1262","title":{"rendered":"Cisco: Trace MAC or IP addresses to switch ports"},"content":{"rendered":"<header class=\"entry-header\">\n<h1 class=\"entry-title\">Cisco: Trace MAC or IP addresses to switch ports<\/h1>\n<\/header>\n<div class=\"post-thumbnail\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" src=\"https:\/\/i0.wp.com\/netlabbuilder.net\/wp-content\/uploads\/Trace-IP-address-to-switch-port.png?fit=1200%2C512\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 88vw, 1200px\" srcset=\"https:\/\/i0.wp.com\/netlabbuilder.net\/wp-content\/uploads\/Trace-IP-address-to-switch-port.png?w=1405 1405w, https:\/\/i0.wp.com\/netlabbuilder.net\/wp-content\/uploads\/Trace-IP-address-to-switch-port.png?resize=300%2C128 300w, https:\/\/i0.wp.com\/netlabbuilder.net\/wp-content\/uploads\/Trace-IP-address-to-switch-port.png?resize=768%2C327 768w, https:\/\/i0.wp.com\/netlabbuilder.net\/wp-content\/uploads\/Trace-IP-address-to-switch-port.png?resize=1024%2C437 1024w, https:\/\/i0.wp.com\/netlabbuilder.net\/wp-content\/uploads\/Trace-IP-address-to-switch-port.png?resize=1200%2C512 1200w\" alt=\"\" width=\"1200\" height=\"512\" \/><\/div>\n<div class=\"entry-content\">\n<p>Sometimes, people ask me to locate switch ports where their machines\/servers are connecting to, given that I have the MAC or IP addresses of their devices.<br \/>\nTo accomplish this task, I used to use a set of commands\u00a0<span id=\"crayon-5b7285eddfe0b791934604\" class=\"crayon-syntax crayon-syntax-inline crayon-theme-cisco-command crayon-theme-cisco-command-inline crayon-font-courier-new\"><span class=\"crayon-pre crayon-code\">show arp<\/span><\/span>,\u00a0<span id=\"crayon-5b7285eddfe12906493202\" class=\"crayon-syntax crayon-syntax-inline crayon-theme-cisco-command crayon-theme-cisco-command-inline crayon-font-courier-new\"><span class=\"crayon-pre crayon-code\">show mac address<\/span><\/span>\u00a0 and\u00a0<span id=\"crayon-5b7285eddfe15756674919\" class=\"crayon-syntax crayon-syntax-inline crayon-theme-cisco-command crayon-theme-cisco-command-inline crayon-font-courier-new\"><span class=\"crayon-pre crayon-code\">show cdp neighbors<\/span><\/span>\u00a0 on different switches in the network.<\/p>\n<p>However, I had found another way\/command which helps me to quickly get the job done. It is\u00a0<span id=\"crayon-5b7285eddfe17162898203\" class=\"crayon-syntax crayon-syntax-inline crayon-theme-cisco-command crayon-theme-cisco-command-inline crayon-font-courier-new\"><span class=\"crayon-pre crayon-code\"><span class=\"crayon-e\">traceroute\u00a0<\/span><span class=\"crayon-v\">mac<\/span><\/span><\/span>\u00a0command with two following options:<\/p>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>traceroute mac source-MAC destination-MAC<\/li>\n<li>traceroute mac ip source-IP destination-IP<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>The command will run a\u00a0<strong>L2 trace<\/strong>\u00a0to identify a path from source address to destination address. The output of this command contains the information of the switch ports where the source and destination hosts are connecting to, and all switch-to-switch connections in between. Bear in mind that you need to run this command on L3 device.<\/p>\n<p>Let me show you how it works with the network diagram above.<\/p>\n<p>Note: all hosts in the network must be reachable from a L3\/Core device. I have to make sure that their IP and MAC addresses shown up when issuing the\u00a0<span id=\"crayon-5b7285eddfe1a171487818\" class=\"crayon-syntax crayon-syntax-inline crayon-theme-cisco-command crayon-theme-cisco-command-inline crayon-font-courier-new\"><span class=\"crayon-pre crayon-code\">show arp<\/span><\/span>\u00a0command<\/p>\n<div id=\"crayon-5b7285eddfe1d652648168\" class=\"crayon-syntax crayon-theme-cisco-command crayon-font-courier-new crayon-os-pc print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"crayon-toolbar\" data-settings=\" show\">\n<p><span class=\"crayon-title\">show arp<\/span><\/p>\n<div class=\"crayon-tools\">\n<div class=\"crayon-button crayon-nums-button crayon-pressed\" title=\"Toggle Line Numbers\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-plain-button\" title=\"Toggle Plain Code\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-wrap-button\" title=\"Toggle Line Wrap\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-copy-button\" title=\"Copy\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-popup-button\" title=\"Open Code In New Window\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<p><span class=\"crayon-language\">Python<\/span><\/p>\n<\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1d652648168-1\">1<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1d652648168-2\">2<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1d652648168-3\">3<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1d652648168-4\">4<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1d652648168-5\">5<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1d652648168-6\">6<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1d652648168-7\">7<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5b7285eddfe1d652648168-1\" class=\"crayon-line\"><span class=\"crayon-v\">Core<\/span><span class=\"crayon-c\">#show arp<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1d652648168-2\" class=\"crayon-line\"><span class=\"crayon-e\">Protocol <\/span><span class=\"crayon-e\">Address\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-e\">Age<\/span> <span class=\"crayon-sy\">(<\/span><span class=\"crayon-k \">min<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-h\">\u00a0\u00a0 <\/span><span class=\"crayon-e\">Hardware <\/span><span class=\"crayon-e\">Addr\u00a0\u00a0 <\/span><span class=\"crayon-k \">Type<\/span><span class=\"crayon-h\">\u00a0\u00a0 <\/span><span class=\"crayon-e\">Interface<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1d652648168-3\" class=\"crayon-line\"><span class=\"crayon-i\">Internet<\/span> <span class=\"crayon-cn\">192.168.100.1<\/span><span class=\"crayon-h\"> \u00a0\u00a0 <\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-h\">\u00a0\u00a0 <\/span><span class=\"crayon-cn\">0035.1aff.80c1<\/span> <span class=\"crayon-e\">ARPA\u00a0\u00a0 <\/span><span class=\"crayon-e\">Vlan100<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1d652648168-4\" class=\"crayon-line\"><span class=\"crayon-i\">Internet<\/span> <span class=\"crayon-cn\">192.168.100.10<\/span><span class=\"crayon-h\"> \u00a0\u00a0 <\/span><span class=\"crayon-cn\">2<\/span><span class=\"crayon-h\">\u00a0\u00a0 <\/span><span class=\"crayon-cn\">00a0.a423.90bc<\/span> <span class=\"crayon-e\">ARPA\u00a0\u00a0 <\/span><span class=\"crayon-e\">Vlan100<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1d652648168-5\" class=\"crayon-line\"><span class=\"crayon-i\">Internet<\/span> <span class=\"crayon-cn\">192.168.100.20<\/span><span class=\"crayon-h\"> \u00a0\u00a0 <\/span><span class=\"crayon-cn\">3<\/span><span class=\"crayon-h\">\u00a0\u00a0 <\/span><span class=\"crayon-cn\">448a.5bbc.ff61<\/span><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-e\">ARPA\u00a0\u00a0 <\/span><span class=\"crayon-e\">Vlan100<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1d652648168-6\" class=\"crayon-line\"><span class=\"crayon-i\">Internet<\/span> <span class=\"crayon-cn\">192.168.200.1<\/span><span class=\"crayon-h\"> \u00a0\u00a0 <\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-h\">\u00a0\u00a0 <\/span><span class=\"crayon-cn\">0035.1aff.80f6<\/span> <span class=\"crayon-e\">ARPA\u00a0\u00a0 <\/span><span class=\"crayon-e\">Vlan200<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1d652648168-7\" class=\"crayon-line\"><span class=\"crayon-i\">Internet<\/span> <span class=\"crayon-cn\">192.168.200.10<\/span><span class=\"crayon-h\"> \u00a0\u00a0 <\/span><span class=\"crayon-cn\">3<\/span><span class=\"crayon-h\">\u00a0\u00a0 <\/span><span class=\"crayon-cn\">40f2.e985.5308<\/span><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-e\">ARPA\u00a0\u00a0 <\/span><span class=\"crayon-v\">Vlan200<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>Case 1<\/strong><\/p>\n<p>If I want to trace the switch ports for devices with IP addresses of\u00a0<strong>192.168.100.20 (448a.5bbc.ff61)<\/strong>\u00a0and\u00a0<strong>192.168.100.10 (00a0.a423.90bc).<\/strong>\u00a0I\u00a0use the following commands and\u00a0place the IP or MAC addresses in either source or destination addresses:<\/p>\n<div id=\"crayon-5b7285eddfe1f294669954\" class=\"crayon-syntax crayon-theme-cisco-command crayon-font-courier-new crayon-os-pc print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"crayon-toolbar\" data-settings=\" show\">\n<p><span class=\"crayon-title\">traceroute mac ip<\/span><\/p>\n<div class=\"crayon-tools\">\n<div class=\"crayon-button crayon-nums-button crayon-pressed\" title=\"Toggle Line Numbers\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-plain-button\" title=\"Toggle Plain Code\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-wrap-button\" title=\"Toggle Line Wrap\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-copy-button\" title=\"Copy\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-popup-button\" title=\"Open Code In New Window\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<p><span class=\"crayon-language\">Python<\/span><\/p>\n<\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1f294669954-1\">1<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1f294669954-2\">2<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1f294669954-3\">3<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1f294669954-4\">4<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1f294669954-5\">5<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1f294669954-6\">6<\/div>\n<div class=\"crayon-num crayon-marked-num crayon-top crayon-bottom\" data-line=\"crayon-5b7285eddfe1f294669954-7\">7<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1f294669954-8\">8<\/div>\n<div class=\"crayon-num crayon-marked-num crayon-top crayon-bottom\" data-line=\"crayon-5b7285eddfe1f294669954-9\">9<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1f294669954-10\">10<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe1f294669954-11\">11<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5b7285eddfe1f294669954-1\" class=\"crayon-line\"><span class=\"crayon-v\">Core<\/span><span class=\"crayon-c\">#traceroute mac ip 192.168.100.20 192.168.100.10<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1f294669954-2\" class=\"crayon-line\"><span class=\"crayon-e\">Translating <\/span><span class=\"crayon-e\">IP <\/span><span class=\"crayon-e\">to <\/span><span class=\"crayon-i\">mac<\/span> <span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1f294669954-3\" class=\"crayon-line\"><span class=\"crayon-cn\">192.168.100.20<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-cn\">448a.5bbc.ff61<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1f294669954-4\" class=\"crayon-line\"><span class=\"crayon-cn\">192.168.100.10<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-cn\">00a0.a423.90bc<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1f294669954-5\" class=\"crayon-line\"><\/div>\n<div id=\"crayon-5b7285eddfe1f294669954-6\" class=\"crayon-line\"><span class=\"crayon-i\">Source<\/span> <span class=\"crayon-cn\">448a.5bbc.ff61<\/span> <span class=\"crayon-e\">found <\/span><span class=\"crayon-e\">on <\/span><span class=\"crayon-i\">Access2<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1f294669954-7\" class=\"crayon-line crayon-marked-line crayon-top crayon-bottom\"><span class=\"crayon-cn\">1<\/span> <span class=\"crayon-v\">Access2<\/span> <span class=\"crayon-o\">:<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">2<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">24<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1f294669954-8\" class=\"crayon-line\"><span class=\"crayon-cn\">2<\/span> <span class=\"crayon-v\">Core<\/span> <span class=\"crayon-o\">:<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">2<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">1<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1f294669954-9\" class=\"crayon-line crayon-marked-line crayon-top crayon-bottom\"><span class=\"crayon-cn\">3<\/span> <span class=\"crayon-v\">Access1<\/span> <span class=\"crayon-o\">:<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">24<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">6<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1f294669954-10\" class=\"crayon-line\"><span class=\"crayon-i\">Destination<\/span> <span class=\"crayon-cn\">00a0.a423.90bc<\/span> <span class=\"crayon-e\">found <\/span><span class=\"crayon-e\">on <\/span><span class=\"crayon-e\">Access1<\/span><\/div>\n<div id=\"crayon-5b7285eddfe1f294669954-11\" class=\"crayon-line\"><span class=\"crayon-i\">Layer<\/span> <span class=\"crayon-cn\">2<\/span> <span class=\"crayon-k \">trace<\/span> <span class=\"crayon-v\">completed<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div id=\"crayon-5b7285eddfe22655448807\" class=\"crayon-syntax crayon-theme-cisco-command crayon-font-courier-new crayon-os-pc print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"crayon-toolbar\" data-settings=\" show\">\n<p><span class=\"crayon-title\">traceroute mac<\/span><\/p>\n<div class=\"crayon-tools\">\n<div class=\"crayon-button crayon-nums-button crayon-pressed\" title=\"Toggle Line Numbers\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-plain-button\" title=\"Toggle Plain Code\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-wrap-button\" title=\"Toggle Line Wrap\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-copy-button\" title=\"Copy\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-popup-button\" title=\"Open Code In New Window\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<p><span class=\"crayon-language\">Python<\/span><\/p>\n<\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe22655448807-1\">1<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe22655448807-2\">2<\/div>\n<div class=\"crayon-num crayon-marked-num crayon-top crayon-bottom\" data-line=\"crayon-5b7285eddfe22655448807-3\">3<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe22655448807-4\">4<\/div>\n<div class=\"crayon-num crayon-marked-num crayon-top crayon-bottom\" data-line=\"crayon-5b7285eddfe22655448807-5\">5<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe22655448807-6\">6<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe22655448807-7\">7<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5b7285eddfe22655448807-1\" class=\"crayon-line\"><span class=\"crayon-v\">Core<\/span><span class=\"crayon-c\">#traceroute mac 448a.5bbc.ff61 00a0.a423.90bc<\/span><\/div>\n<div id=\"crayon-5b7285eddfe22655448807-2\" class=\"crayon-line\"><span class=\"crayon-i\">Source<\/span> <span class=\"crayon-cn\">448a.5bbc.ff61<\/span> <span class=\"crayon-e\">found <\/span><span class=\"crayon-e\">on <\/span><span class=\"crayon-i\">Access2<\/span><\/div>\n<div id=\"crayon-5b7285eddfe22655448807-3\" class=\"crayon-line crayon-marked-line crayon-top crayon-bottom\"><span class=\"crayon-cn\">1<\/span> <span class=\"crayon-v\">Access2<\/span> <span class=\"crayon-o\">:<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">2<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">24<\/span><\/div>\n<div id=\"crayon-5b7285eddfe22655448807-4\" class=\"crayon-line\"><span class=\"crayon-cn\">2<\/span> <span class=\"crayon-v\">Core<\/span> <span class=\"crayon-o\">:<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">2<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">1<\/span><\/div>\n<div id=\"crayon-5b7285eddfe22655448807-5\" class=\"crayon-line crayon-marked-line crayon-top crayon-bottom\"><span class=\"crayon-cn\">3<\/span> <span class=\"crayon-v\">Access1<\/span> <span class=\"crayon-o\">:<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">24<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">6<\/span><\/div>\n<div id=\"crayon-5b7285eddfe22655448807-6\" class=\"crayon-line\"><span class=\"crayon-i\">Destination<\/span> <span class=\"crayon-cn\">00a0.a423.90bc<\/span> <span class=\"crayon-e\">found <\/span><span class=\"crayon-e\">on <\/span><span class=\"crayon-e\">Access1<\/span><\/div>\n<div id=\"crayon-5b7285eddfe22655448807-7\" class=\"crayon-line\"><span class=\"crayon-i\">Layer<\/span> <span class=\"crayon-cn\">2<\/span> <span class=\"crayon-k \">trace<\/span> <span class=\"crayon-v\">completed<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>The outputs tell me that source device (IP: 192.168.100.20 and MAC: 448a.5bbc.ff61) is on port G0\/2 of Access2 switch and the destination device (IP: 192.168.100.10 and MAC: 00a0.a423.90bc) is on port G0\/6 of Access1 switch.<\/p>\n<p><strong>Case 2<\/strong><\/p>\n<p>I want to trace the switch ports for devices with IP addresses of\u00a0<strong>192.168.200.10\u00a0<\/strong>(<strong>40f2.e985.5308<\/strong>) and\u00a0<strong>192.168.100.20<\/strong>\u00a0(<strong>448a.5bbc.ff61<\/strong>). I notice that they are\u00a0<strong>NOT<\/strong>\u00a0<strong>in the same subnet\/vlan<\/strong>\u00a0(192.168.200.0\/24 vs 192.168.100.0\/24, and Vlan 200 vs Vlan 100):<\/p>\n<div id=\"crayon-5b7285eddfe25013100357\" class=\"crayon-syntax crayon-theme-cisco-command crayon-font-courier-new crayon-os-pc print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"crayon-toolbar\" data-settings=\" show\">\n<p><span class=\"crayon-title\">traceroute mac ip<\/span><\/p>\n<div class=\"crayon-tools\">\n<div class=\"crayon-button crayon-nums-button crayon-pressed\" title=\"Toggle Line Numbers\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-plain-button\" title=\"Toggle Plain Code\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-wrap-button\" title=\"Toggle Line Wrap\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-copy-button\" title=\"Copy\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-popup-button\" title=\"Open Code In New Window\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<p><span class=\"crayon-language\">Python<\/span><\/p>\n<\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe25013100357-1\">1<\/div>\n<div class=\"crayon-num crayon-marked-num crayon-top crayon-bottom\" data-line=\"crayon-5b7285eddfe25013100357-2\">2<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5b7285eddfe25013100357-1\" class=\"crayon-line\"><span class=\"crayon-v\">Core<\/span><span class=\"crayon-c\">#traceroute mac ip 192.168.200.10 192.168.100.20<\/span><\/div>\n<div id=\"crayon-5b7285eddfe25013100357-2\" class=\"crayon-line crayon-marked-line crayon-top crayon-bottom\"><span class=\"crayon-e\">Source <\/span><span class=\"crayon-st\">and<\/span> <span class=\"crayon-e\">Destination <\/span><span class=\"crayon-e\">are <\/span><span class=\"crayon-st\">not<\/span> <span class=\"crayon-e\">on <\/span><span class=\"crayon-e\">same <\/span><span class=\"crayon-v\">subnet<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div id=\"crayon-5b7285eddfe27809689314\" class=\"crayon-syntax crayon-theme-cisco-command crayon-font-courier-new crayon-os-pc print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"crayon-toolbar\" data-settings=\" show\">\n<p><span class=\"crayon-title\">traceroute mac<\/span><\/p>\n<div class=\"crayon-tools\">\n<div class=\"crayon-button crayon-nums-button crayon-pressed\" title=\"Toggle Line Numbers\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-plain-button\" title=\"Toggle Plain Code\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-wrap-button\" title=\"Toggle Line Wrap\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-copy-button\" title=\"Copy\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-popup-button\" title=\"Open Code In New Window\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<p><span class=\"crayon-language\">Python<\/span><\/p>\n<\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe27809689314-1\">1<\/div>\n<div class=\"crayon-num crayon-marked-num crayon-top crayon-bottom\" data-line=\"crayon-5b7285eddfe27809689314-2\">2<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe27809689314-3\">3<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5b7285eddfe27809689314-1\" class=\"crayon-line\"><span class=\"crayon-v\">Core<\/span><span class=\"crayon-c\">#traceroute mac 40f2.e985.5308 448a.5bbc.ff61<\/span><\/div>\n<div id=\"crayon-5b7285eddfe27809689314-2\" class=\"crayon-line crayon-marked-line crayon-top crayon-bottom\"><span class=\"crayon-v\">Error<\/span><span class=\"crayon-o\">:<\/span> <span class=\"crayon-e\">Source <\/span><span class=\"crayon-st\">and<\/span> <span class=\"crayon-e\">destination <\/span><span class=\"crayon-e\">macs <\/span><span class=\"crayon-e\">are <\/span><span class=\"crayon-e\">on <\/span><span class=\"crayon-e\">different <\/span><span class=\"crayon-v\">vlans<\/span><span class=\"crayon-sy\">.<\/span><\/div>\n<div id=\"crayon-5b7285eddfe27809689314-3\" class=\"crayon-line\"><span class=\"crayon-e\">Layer2 <\/span><span class=\"crayon-k \">trace<\/span> <span class=\"crayon-v\">aborted<\/span><span class=\"crayon-sy\">.<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>I get nothing but error messages.<br \/>\nAs mentioned earlier, this is a\u00a0<strong>L2 trace<\/strong>, if I use the source and destination IPs in different subnets, it will not work at all. Instead, I will get the message \u201cSource and Destination are not on same subnet\u201d, with MAC addresses, it is \u201cError: Source and destination macs are on different vlans.\u201d<\/p>\n<p>To overcome this issue, I would like to pick two additional IP or MAC addresses, one in 192.168.200.0\/24 (Vlan 200) and the other in 192.168.100.0\/24 (Vlan 100), which are in the same subnets\/vlans with IP or MAC addresses above.<\/p>\n<p>I can easily find them in ARP table, but it would be more convenient when I take the IP addresses of Interface Vlan 100 and 200 because they are already in my memory.<\/p>\n<div id=\"crayon-5b7285eddfe2a402859204\" class=\"crayon-syntax crayon-theme-cisco-command crayon-font-courier-new crayon-os-pc print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"crayon-toolbar\" data-settings=\" show\">\n<p><span class=\"crayon-title\">traceroute mac ip<\/span><\/p>\n<div class=\"crayon-tools\">\n<div class=\"crayon-button crayon-nums-button crayon-pressed\" title=\"Toggle Line Numbers\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-plain-button\" title=\"Toggle Plain Code\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-wrap-button\" title=\"Toggle Line Wrap\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-copy-button\" title=\"Copy\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-popup-button\" title=\"Open Code In New Window\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<p><span class=\"crayon-language\">Python<\/span><\/p>\n<\/div>\n<\/div>\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe2a402859204-1\">1<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe2a402859204-2\">2<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe2a402859204-3\">3<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe2a402859204-4\">4<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe2a402859204-5\">5<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe2a402859204-6\">6<\/div>\n<div class=\"crayon-num crayon-marked-num crayon-top crayon-bottom\" data-line=\"crayon-5b7285eddfe2a402859204-7\">7<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe2a402859204-8\">8<\/div>\n<div class=\"crayon-num crayon-marked-num crayon-top crayon-bottom\" data-line=\"crayon-5b7285eddfe2a402859204-9\">9<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-5b7285eddfe2a402859204-10\">10<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-5b7285eddfe2a402859204-1\" class=\"crayon-line\"><span class=\"crayon-v\">Core<\/span><span class=\"crayon-c\">#traceroute mac ip 192.168.200.1 192.168.200.10<\/span><\/div>\n<div id=\"crayon-5b7285eddfe2a402859204-2\" class=\"crayon-line\"><span class=\"crayon-e\">Translating <\/span><span class=\"crayon-e\">IP <\/span><span class=\"crayon-e\">to <\/span><span class=\"crayon-i\">mac<\/span> <span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">.<\/span><\/div>\n<div id=\"crayon-5b7285eddfe2a402859204-3\" class=\"crayon-line\"><span class=\"crayon-cn\">192.168.200.1<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-cn\">0035.1aff.80f6<\/span><\/div>\n<div id=\"crayon-5b7285eddfe2a402859204-4\" class=\"crayon-line\"><span class=\"crayon-cn\">192.168.200.10<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-cn\">40f2.e985.5308<\/span><\/div>\n<div id=\"crayon-5b7285eddfe2a402859204-5\" class=\"crayon-line\"><\/div>\n<div id=\"crayon-5b7285eddfe2a402859204-6\" class=\"crayon-line\"><span class=\"crayon-i\">Source<\/span> <span class=\"crayon-cn\">0035.1aff.80f6<\/span> <span class=\"crayon-e\">found <\/span><span class=\"crayon-e\">on <\/span><span class=\"crayon-i\">Core<\/span><\/div>\n<div id=\"crayon-5b7285eddfe2a402859204-7\" class=\"crayon-line crayon-marked-line crayon-top crayon-bottom\"><span class=\"crayon-cn\">1<\/span> <span class=\"crayon-v\">Core<\/span> <span class=\"crayon-o\">:<\/span> <span class=\"crayon-v\">Vl200<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">2<\/span><\/div>\n<div id=\"crayon-5b7285eddfe2a402859204-8\" class=\"crayon-line\"><span class=\"crayon-cn\">2<\/span> <span class=\"crayon-v\">Access2<\/span> <span class=\"crayon-o\">:<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">24<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-v\">Gi0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">3<\/span><\/div>\n<div id=\"crayon-5b7285eddfe2a402859204-9\" class=\"crayon-line crayon-marked-line crayon-top crayon-bottom\"><span class=\"crayon-i\">Destination<\/span> <span class=\"crayon-cn\">40f2.e985.5308<\/span> <span class=\"crayon-e\">found <\/span><span class=\"crayon-e\">on <\/span><span class=\"crayon-e\">Access2<\/span><\/div>\n<div id=\"crayon-5b7285eddfe2a402859204-10\" class=\"crayon-line\"><span class=\"crayon-i\">Layer<\/span> <span class=\"crayon-cn\">2<\/span> <span class=\"crayon-k \">trace<\/span> <span class=\"crayon-v\">completed<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>It works perfectly! The source device is Core switch (Interface Vlan 200, IP: 192.168.200.1 and MAC: 0035.1aff.80f6) and the destination device (IP: 192.168.200.10, MAC: 40f2.e985.5308) is on port G0\/3 of Access2 switch.<\/p>\n<p>If you run the command and face the error massage \u201cMac found on multiple vlans\u201d, it is because the source or destination MAC address belongs to multiple VLANs, you need to indicate the VLAN where they belong to:<\/p>\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li>\u00a0traceroute mac source-MAC destination-MAC vlan VLAN_ID<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Ngu\u1ed3n:\u00a0http:\/\/netlabbuilder.net\/cisco-trace-mac-or-ip-addresses-to-switch-ports\/<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Cisco: Trace MAC or IP addresses to switch ports Sometimes, people ask me to locate switch ports where their machines\/servers [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[33,25,16,19,6],"tags":[],"class_list":["post-1262","post","type-post","status-publish","format-standard","hentry","category-ccnp-tshoot","category-cisco","category-courses","category-issues","category-networking"],"_links":{"self":[{"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=\/wp\/v2\/posts\/1262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1262"}],"version-history":[{"count":0,"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=\/wp\/v2\/posts\/1262\/revisions"}],"wp:attachment":[{"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}