The Command Line- Ciscco Wired Host Networking
A command-line interface ( CLI) is interactive: the user types commands, and the host returns some response, usually text.
Network engineers tend to work with CLIs more than GUIs because
• CLIs tend to respond more quickly.
• CLIs require fewer resources so they can be implemented in a broader range of devices.
• Text output typically contains a higher density of textual information than GUIs.
• CLIs are more amenable to automation.
Powershell is the best tool on a Windows 11 host to access a command line. Most Windows hosts have Powershell installed, but it is available in the Microsoft Store if not. To display the physical interface from Powershell, use the command getmac /v from the CLI prompt, as shown in Figure 4-4.
Figure 4-4 Displaying the Physical Interface Address from Powershell Each interface has a single line of output with the following:
• Connection Name: Matches the interface name in GUI
• Network Adapter: Identifies the Interface manufacturer
• Physical Address: Indicates whether the interface has a physical interface
• Transport Name: Indicates the name of the protocol running over (or bound to) this interface
IPv4 and IPv6 information can be discovered by running a different command, ipconfig /all, as shown in Figure 4-5.
Figure 4-5 Interface Configuration Information on Windows 11
The same basic information (IPv4 address, IPv6 address, subnet mask, etc.) is available here as the GUI, but additional information is also available. In particular:
• The IPv6 DUID, described in Chapter 2, “Addresses”
• The physical interface address
• The default gateway
In most situations, starting Powershell and running ipconfig/all is the quickest way to find all the network information you need about a host. The ipconfig command can be used for more than showing current configuration information; it can also be used to
• /release: Release DHCP-learned IPv4 addresses
• /renew: Renew the DHCP-learned IPv4 addresses
• /release6: Release DHCP-learned IPv6 addresses
• /renew6: Renew DHCP-learned IPv6 addresses
• /flushdns: Flush the local DNS cache
Note Chapter 15, “Application Transport, ” considers the ipconfig DNS commands in more detail.
Note You can change the host’s IP address from Powershell using the netsh command. Using netsh is outside the scope of this book.
Two other pieces of network information that are available from Powershell are difficult to find in any GUI display: the local ARP cache and routing table. To see the local ARP cache, use the arp -a command, as shown in Figure 4-6.
Figure 4-6 Showing the ARP Cache in Powershell Each IP address is shown with its matching physical address in the table. Addresses marked dynamic were learned using ARP.
Addresses marked static are embedded in the operating system software; for instance, the IP broadcast address (255.255.255.255) is always mapped to the physical interface broadcast address (ff-ff-ff-ff-ff-ff).
Figure 4-7 illustrates the Windows 11 host routing table, as displayed when using the Get-NetRoute command from Powershell.
Figure 4-7 The Windows Host Routing Table Several fields are of interest in the output shown in Figure 4-7:
• ifIndex: Indicates which interface to send packets through when following this route.
• DestinationPrefix: Indicates the destination network.
• NextHop: Identifies where to send packets to reach this destination; 0.0.0.0 means “this device” or the local host.
• RouteMetric: Indicates the metric, or cost to reach this destination. Windows hosts use the hop count as a metric.
• ifMetric: Indicates the default metric for routes reachable through this interface.
macOS
Apple’s macOS is the operating system used by every Macintosh computer. There are three ways to display physical and interface addresses on computers running macOS: the GUI, the CLI, and the System Information application.