Mellanox Switch Getting Started: First-Time Setup and CLI Basics - 夜莺博客

Mellanox Switch Getting Started: First-Time Setup and CLI Basics

A new Mellanox (now NVIDIA) Ethernet or InfiniBand switch arrives with no configuration, and the fastest way to bring it up is the serial console, the built-in setup wizard, and a handful of CLI commands that are consistent across the whole MLNX-OS family. This article walks through the first-time setup flow documented by NVIDIA support: initial wizard answers, entering configuration mode, saving the configuration, and the show commands used to verify interface status.

Step 1: Initial Wizard Setup

Connect the console port to a COM port on a management server, power on the switch, and the first-run wizard will ask for the hostname and DHCP preference:

Use DHCP on mt0 interface? [yes/no]: no
Enter hostname: sw-mlnx-01

If the management port uses DHCP, map the MAC address printed on the MGT1 label to a static reservation on your DHCP server so the switch always receives the same management IP.

Step 2: CLI Modes

MLNX-OS uses an industry-standard three-level CLI:

switch >               # Standard mode (read-only)
switch > enable
switch #               # Enable mode (state + actions)
switch # configure terminal
switch (config) #      # Config mode (full read/write)

You cannot jump directly from Standard to Config mode - always pass through enable. Tab completion and ? help are available everywhere, and most commands accept shortened forms (en for enable).

Step 3: Configure and Save

switch (config) # hostname sw-mlnx-01
switch (config) # interface ethernet 1/1
switch (config interface ethernet 1/1) # description uplink-to-spine
switch (config interface ethernet 1/1) # exit
switch (config) # configuration write
switch (config) # show running-config

configuration write is the MLNX-OS equivalent of Cisco's write memory - without it the running configuration is lost on reboot. Use show running-config to review what would be restored.

Step 4: Verify Interfaces

switch (config) # show interfaces ethernet status
switch (config) # show interfaces ethernet 1/1
switch # show interfaces ib status      # InfiniBand switches only

The Ethernet status output shows admin state, operational state and speed per port - the first place to look when a server link is down.

Output Filtering and Monitoring

Instead of grep, MLNX-OS filters show output with pipe operators, and the watch option refreshes automatically:

switch (config) # show interfaces ethernet status | include down
switch (config) # show interfaces counters | exclude 0 | watch interval 2
switch (config) # show running-config | count
switch (config) # show interfaces ethernet status | json-print

| json-print renders show output as JSON - useful when you are scripting the switch, though it cannot be combined with filters or watch.

Related Reading on This Site

See the Mellanox MLNX-OS CLI getting started commands and ToR switch selection guide for choosing and onboarding this class of hardware.

Before You Power On: Console and Cabling

A Mellanox switch ships with no configuration at all — no management IP, no user account beyond the default, and no DHCP client state until it finishes booting. That makes the serial console the only guaranteed way in, and it is worth getting the cable right before you rack the unit.

  • Console port: RJ-45 on most SN2xxx/SN4xxx and QM-series systems, with a DE-9 or USB adapter to your laptop. Some older SX-series and the SX1012 use a mini-USB console; check the label before hunting for a straight-through cable.
  • Serial parameters: 115200 baud, 8 data bits, no parity, 1 stop bit, no flow control. The classic 9600 8N1 default of Cisco and Juniper does not apply here — a blank terminal is almost always a wrong baud rate.
  • Out-of-band management: the MGT1 port is separate from the data plane and is the address you will actually manage the switch on. Print the MAC from the MGT1 label into your DHCP scope or assign a static address on first login.

Power on and watch the boot log to completion. MLNX-OS reports the platform model, the software image version and the Ethernet/InfiniBand mode near the end of the boot sequence — capture that output, because the image family determines which commands exist later.

Step 1: Initial Wizard Setup

Connect the console port to a COM port on a management server, power on the switch, and the first-run wizard will ask for the hostname and DHCP preference:

Use DHCP on mt0 interface? [yes/no]: no
Enter hostname: sw-mlnx-01

If the management port uses DHCP, map the MAC address printed on the MGT1 label to a static reservation on your DHCP server so the switch always receives the same management IP. Answer no to DHCP only when you intend to set the address by hand immediately after login — leaving the interface with neither DHCP nor a static address is the most common reason a brand-new switch appears unreachable.

The wizard also prompts for the admin password and enables the relevant management protocols. Change the default password here; MLNX-OS will accept a short password on first boot, and a switch with a factory admin credential on a management VLAN is a finding waiting to be written up.

Step 2: CLI Modes

MLNX-OS uses an industry-standard three-level CLI:

switch >               # Standard mode (read-only)
switch > enable
switch #               # Enable mode (state + actions)
switch # configure terminal
switch (config) #      # Config mode (full read/write)

You cannot jump directly from Standard to Config mode — always pass through enable. Tab completion and ? help are available everywhere, and most commands accept shortened forms (en for enable). The prompt itself tells you where you are: a > means nothing can be changed, a # means state-changing commands are available, and a parenthesised (config) prefix means you are editing the candidate configuration.

switch > ?                        # list commands available at this level
switch > show ver                 # TAB completion expands to 'show version'
switch # show running-config interface ethernet 1/1
switch # exit                     # step back one level

The deeper prompt levels follow the same pattern — (config interface ethernet 1/1), (config vlan 10), (config ip route) — and exit always returns you one level up. The shortcut do <command> runs an enable-mode command without leaving configuration mode, which saves a lot of round trips during setup.

Step 3: Configure and Save

switch (config) # hostname sw-mlnx-01
switch (config) # interface ethernet 1/1
switch (config interface ethernet 1/1) # description uplink-to-spine
switch (config interface ethernet 1/1) # exit
switch (config) # configuration write
switch (config) # show running-config

configuration write is the MLNX-OS equivalent of Cisco's write memory — without it the running configuration is lost on reboot. Use show running-config to review what would be restored. This single habit prevents the most common MLNX-OS incident: hours of configuration work lost to a power cycle because nobody wrote the configuration to flash.

switch (config) # configuration write to /tmp/sw-mlnx-01.cfg
switch (config) # configuration write
switch # show configuration files

The switch keeps a running configuration, a saved startup configuration, and a set of named configuration files that can be written to local storage or copied to a remote server. Keeping a versioned copy outside the device is what makes a failed upgrade recoverable, and the mechanics are the same ones described in MLNX-OS configuration management.

Step 4: Management Interface and Default Route

The switch is only reachable if the management interface and its default gateway are both correct. Set them explicitly rather than relying on DHCP if the address is to be permanent:

switch (config) # interface mgmt0 ip address 10.10.20.11 /24
switch (config) # ip route default nexthop 10.10.20.1
switch (config) # interface mgmt0 dhcp disable
switch (config) # configuration write
switch # show ip route
switch # show interface mgmt0

Two details catch people out. First, the management interface is named mgmt0 on the CLI even though the physical port is labelled MGT1 — the naming differs because the port is the second member of the management pair on some systems. Second, the default route must point at the management VLAN gateway, not at a data-plane next hop; a route learned through the data plane will not survive a management-plane outage. Confirm with show ip route that the default entry appears with the expected next hop and an active state.

Step 5: Verify Interfaces and Optics

switch (config) # show interfaces ethernet status
switch (config) # show interfaces ethernet 1/1
switch # show interfaces ib status      # InfiniBand switches only
switch # show interfaces ethernet 1/1 transceiver

The Ethernet status output shows admin state, operational state and speed per port — the first place to look when a server link is down. The per-port detail adds counters, error rates and the negotiated speed, and the transceiver view reports the optic's vendor, part number and optical power levels. A port that reports up with a high error or discards rate, or a receive power at the edge of the optic's budget, is the root cause of far more "slow network" tickets than any routing misconfiguration.

On InfiniBand platforms, the equivalent command reports the link width and speed rather than an Ethernet speed; a link trained at 4x instead of 12x is usually a cable or splitter problem, not a switch problem.

Step 6: Users, SSH and NTP

A switch on a management VLAN should be reachable over SSH and should know what time it is — the second point matters because every counter, log line and SNMP trap is timestamped with the local clock.

switch (config) # username admin password MyStrongPass123 privilege admin
switch (config) # no ssh server enable
switch (config) # ssh server enable
switch (config) # ntp server 10.10.20.5
switch (config) # ntp enable
switch (config) # logging host 10.10.20.6
switch (config) # configuration write
switch # show ntp
switch # show logging

Pointing syslog at a central collector means the next failure leaves a record outside the device. Combined with NTP, that record is correlatable with the rest of the estate — which is the whole difference between "the switch rebooted at some point" and "the switch rebooted 12 seconds after the uplink flapped". For monitoring beyond syslog, the SNMP patterns in SNMPv3 authPriv apply to MLNX-OS as well.

Output Filtering and Monitoring

Instead of grep, MLNX-OS filters show output with pipe operators, and the watch option refreshes automatically:

switch (config) # show interfaces ethernet status | include down
switch (config) # show interfaces counters | exclude 0 | watch interval 2
switch (config) # show running-config | count
switch (config) # show interfaces ethernet status | json-print

| json-print renders show output as JSON — useful when you are scripting the switch, though it cannot be combined with filters or watch. The include, exclude and count operators accept regular expressions, so | include 1/1[0-9] is a legitimate way to focus on a port block. More filtering patterns, including the watch and grep-style operators and their limits, are collected in MLNX-OS CLI troubleshooting with filters and watch.

Common First-Boot Problems

  • Blank console. Wrong baud rate (should be 115200) or a null-modem adapter where a straight-through is required. Try 9600 8N1 as a fallback before assuming the unit is dead.
  • Switch boots into the wrong personality. Some platforms ship with an Ethernet image and require an explicit switch to InfiniBand mode (or back). Confirm the running image with show version before building configuration on top of it.
  • Wizard answers lost. If the configuration was never written, a reboot reverts hostname, management addressing and users. configuration write after every meaningful change is the fix.
  • Management unreachable from outside the subnet. Almost always a missing or wrong default route on mgmt0, not a firewall.
  • All ports administratively up but operationally down. Check the optic with show interfaces ethernet <port> transceiver and confirm the far end is not in a different admin state; MLNX-OS does not shut ports by default, so a down link is nearly always physical.

The full command surface for daily operation — interface naming, port configuration and the show commands worth memorising — is covered in Mellanox MLNX-OS CLI getting started commands, with a deeper walkthrough of the console sequence in MLNX-OS first-time setup wizard. When you are choosing which platform to buy in the first place, the criteria in our ToR switch selection guide apply to 25/100/200GbE Mellanox systems as much as to any other vendor.

Frequently Asked Questions

Is enable password-protected by default? No. The default configuration leaves enable mode open, which is why setting an admin password and enabling SSH-only access is part of first-time setup rather than an afterthought.

Can I manage the switch over the data plane instead of MGT1? You can give a data-plane interface an IP address, but doing so couples management reachability to the production fabric. Keep management on mgmt0 and use the data plane for service traffic.

What happens if I forget to run configuration write? The running configuration survives until the next reload and is then lost, reverting the switch to its saved startup configuration. There is no automatic prompt — MLNX-OS will not warn you before a reboot.

How do I factory-reset the switch? The MLNX-OS command is reset factory from enable mode, which clears the configuration and reboots. Export a configuration file to a remote server first; the reset does not offer to back anything up.

原文链接:https://enterprise-support.nvidia.com/s/article/howto-get-started-with-mellanox-switches