{"id":606,"date":"2016-06-20T13:52:17","date_gmt":"2016-06-20T08:22:17","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=606"},"modified":"2026-09-03T15:06:09","modified_gmt":"2026-09-03T09:36:09","slug":"random-useful-switch-commands","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/random-useful-switch-commands\/","title":{"rendered":"Essential Switch Commands for Network Administration"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Network switches are commonly managed through command-line interfaces for monitoring ports, identifying connected devices, managing VLANs, checking port status, and reviewing system logs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, we have listed a few useful switch commands that can be used in day-to-day network administration and troubleshooting. These commands can help administrators quickly identify MAC addresses, switch ports, VLAN information, port speed, configuration status, and recent switch logs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before executing the commands, ensure that you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Access to the switch command-line interface.<\/li>\n\n\n\n<li>The required administrative privileges.<\/li>\n\n\n\n<li>Basic knowledge of switch ports and VLANs.<\/li>\n\n\n\n<li>The required MAC address, VLAN number, or port number, where applicable.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Implementation<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Find the Switch Port Associated with a MAC Address<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To get the switch port of a MAC address, use the following command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># show mac address-table address xx:xx:xx:xx:xx:xx\nAging time is 300 sec\n\nVlan Mac Address Port Type\n\u2014\u2014\u2013 \u2014\u2014\u2014\u2014\u2014\u2014\u2014 \u2014\u2014\u2014- \u2014\u2014\u2014-\n\n100 xx:xx:xx:xx:xx:xx gi1\/0\/12 dynamic<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command can be used to identify the switch port associated with a specific MAC address.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. View the MAC Address of a Switch Port<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To view the MAC address associated with a switch port, execute the following command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># show mac address-table interface gi1\/0\/2\nAging time is 300 sec\n\nVlan Mac Address Port Type\n\u2014\u2014\u2013 \u2014\u2014\u2014\u2014\u2014\u2014\u2014 \u2014\u2014\u2014- \u2014\u2014\u2014-\n100 xx:xx:xx:xx:xx:xx gi1\/0\/2 dynamic<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. View the VLAN and Administrative Mode of a Switch Port<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To view the VLAN and administrative mode of a switch port, execute the following command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#show interfaces switchport gi1\/0\/12\n\n\u2026\u2026..\n\nAdministrative Mode: access\n\nAccess Mode VLAN: 100<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. Check the Speed of a Switch Port<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To get the speed of a switch port, use the following command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># show interfaces status gi1\/0\/12\n\nFlow Link Back Mdix\nPort Type Duplex Speed Neg ctrl State Pressure Mode\n\u2014\u2014\u2013 \u2014\u2014\u2014\u2014 \u2014\u2014 \u2014\u2013 \u2014\u2014\u2013 \u2014- \u2014\u2014\u2014\u2013 \u2014\u2014\u2013 \u2014\u2014-\ngi1\/0\/12 1G-Copper Full 100 Enabled On Up Disabled Off<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. Change the VLAN of a Switch Port<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To change the VLAN of a switch port, follow the steps below.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#configure\n\n(config)#interface gi1\/0\/&lt;port number>\n\n(config-if)#switchport access vlan 100<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. Configure a Switch Port for Trunking<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To trunk a switch port to different VLANs, execute the following commands.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#configure\n\n(config)#interface gi1\/0\/&lt;port number>\n\n(config-if)#switchport mode trunk\n\n(config-if)#switchport trunk allowed vlan add &lt;vlan number1> &lt;vlan number2>\n\n(config-if)#end<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">7. Shut Down a Single Switch Port<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To shut down a single port, execute the following commands.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#configure\n\n(config)#interface gi1\/0\/&lt;port number>\n\n(config-if)# shutdown<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">8. Copy the Running Configuration to the Startup Configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To copy the running configuration to the startup configuration, execute the following command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#copy running-config startup-config<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">9. Add a New VLAN to the Database<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To add a new VLAN to the database, follow the steps below.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#configure\n\n#vlan database\n\n# vlan &lt;vlan number><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">10. View All Switch Ports Belonging to a Particular VLAN<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To view all the switch ports that belong to a particular VLAN, execute the following command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">show vlan tag &lt;vlan number><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This will list all the switch ports that belong to the specified VLAN.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">11. View Recent Switch Logs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To view the recent logs on the switch, execute the following command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">show logging<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Switch command-line tools provide a quick and practical way to monitor and manage network infrastructure. The commands covered in this article can be used for common day-to-day tasks such as identifying connected devices, checking switch ports, managing VLANs, configuring trunk ports, saving configurations, and reviewing switch logs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Keeping these commonly used commands available as a quick reference can help network administrators perform routine configuration and troubleshooting tasks more efficiently.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions (FAQ)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. How can I find which switch port is connected to a specific MAC address?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">show mac address-table address &lt;mac-address><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This helps identify the switch port associated with the specified MAC address.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. How can I check the VLAN assigned to a switch port?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">show interfaces switchport &lt;interface><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This displays information such as the administrative mode and VLAN associated with the switch port.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. How can I view the recent logs on a switch?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">show logging<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This displays the recent log information available on the switch.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Article<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/configure-vnc-virtual-network-computing-in-centos\/\">How to Configure VNC (Virtual Network Computing) on CentOS<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to our experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Have a technology challenge or looking for the right solution for your business? Our experienced team can help with development, cloud, DevOps, design, and other technology requirements. <strong><a href=\"https:\/\/pheonixsolutions.com\/contact\" data-type=\"link\" data-id=\"https:\/\/pheonixsolutions.com\/contact\">Get in touch with our experts.<\/a><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Network switches are commonly managed through command-line interfaces for monitoring ports, identifying connected devices, managing VLANs, checking port status, [&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":"default","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":"","ast-disable-related-posts":"","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-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":"","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-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":"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":""},"mobile":{"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":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-606","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-9M","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/606","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=606"}],"version-history":[{"count":2,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/606\/revisions"}],"predecessor-version":[{"id":11337,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/606\/revisions\/11337"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}