The Terminal Command Line- Ciscco Wired Host Networking

Like most other hosts, Apple Macintosh computers have a command line you can use to examine and configure network parameters. You can typically find an application called Terminal under Applications, Utilities in the Finder app. Once you have launched the terminal, you can display the network configuration using  ifconfig, as shown in Figure 4-10.

Figure 4-10 macOS ifconfig

A lot of information here will not look familiar because macOS provides a lot more information from the physical interfaces than Windows does (there are ways to get this information in Windows, but they involve using different commands than ifconfig). Most of this information, however, is not very useful for the average operator.

The important fields are

• en0 is the service name of the interface.

• ether bc contains the physical address.

• inet6 contains the IPv6 interface address and prefix length.

• inet contains the IPv4 interface address and subnet mask.

The output does not include the default gateway.

If you need to release and renew the DHCP-assigned IP address in macOS, you use a pair of commands: sudo ipconfig set en0 BOOTP; sudo ipconfig set en0 DHCP Make sure you replace en0 with the correct interface name.

This first command sets the interface to retrieve a new IP address via the bootp protocol and forces the interface to release the DHCP learned address. Since bootp is no longer widely used, the interface will (most likely) not have an address once the first command is run.

The second command tells the host to ask for a new DHCP address from the server.

Note

Because DHCP servers store mappings between host physical addresses and assigned IP addresses, a host will probably receive the same address after the renewal as it had before.

In macOS, unlike Windows 11, you can use the ifconfig command to set the IP address for an interface manually.

However, because macOS manages IP addresses as part of a central configuration system configd, any address you set using ifconfig will be overwritten by configd.

You can tell configd to change the IP address on an interface using the command networksetup.