How to use the command 'airport' (with examples)

How to use the command 'airport' (with examples)

  • Osx
  • December 25, 2023

The ‘airport’ command is a wireless network configuration utility in macOS. It allows users to manage and interact with their Wi-Fi networks. This article provides examples of different use cases for the ‘airport’ command.

Use case 1: Show current wireless status information

Code:

airport --getinfo

Motivation:

The ‘airport –getinfo’ command is used to retrieve information about the current wireless network status. This can be helpful when troubleshooting network connectivity issues or simply to gather details about the active Wi-Fi connection.

Explanation:

  • airport: The command itself.
  • --getinfo: This argument tells the command to retrieve the wireless status information.

Example output:

     agrCtlRSSI: -55
    agrExtRSSI: 0
          state: running
        op mode: station 
     lastTxRate: 585
        maxRate: 866
lastAssocStatus: 0
    802.11 auth: open
    link auth: wpa2-psk
         BSSID: 00:00:00:00:00:00
          SSID: MyWiFiNetwork
           MCS: 9
       channel: 11,1

Use case 2: Sniff wireless traffic on channel 1

Code:

airport sniff 1

Motivation:

The ‘airport sniff’ command allows users to monitor and capture wireless traffic on a specific channel. This can be useful for network analysis or troubleshooting issues related to wireless communication.

Explanation:

  • airport: The command itself.
  • sniff: This argument tells the command to begin capturing wireless traffic.
  • 1: The channel number on which to sniff the traffic.

Example output:

Capturing on 'Wi-Fi: en0'
Sniffing on channel 1:
...

Use case 3: Scan for available wireless networks

Code:

airport --scan

Motivation:

The ‘airport –scan’ command is used to scan for available wireless networks in the vicinity. This can help users identify nearby networks, their signal strength, and other details when looking for a Wi-Fi network to connect to.

Explanation:

  • airport: The command itself.
  • --scan: This argument tells the command to initiate a scan for available wireless networks.

Example output:

SSID BSSID             RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
MyWiFiNetwork 00:00:00:00:00:01 -65  1     N  -- WPA2(PSK/AES/AES)
OtherNetwork   00:00:00:00:00:02 -70  11    Y  US WPA(PSK/TKIP/TKIP) WPA2(PSK/AES/AES)

Use case 4: Disassociate from current airport network

Code:

sudo airport --disassociate

Motivation:

The ‘airport –disassociate’ command is used to forcefully disconnect from the current airport network. This can be helpful in scenarios where there are issues with the network connection or to simply disconnect from the current network.

Explanation:

  • sudo: This command is used to execute the ‘airport’ command with administrator privileges.
  • airport: The command itself.
  • --disassociate: This argument tells the command to terminate the current network connection.

Example output:

[SUCCESS] Disassociate successful.

Conclusion:

The ‘airport’ command provides a range of functionalities for managing wireless networks in macOS. From retrieving network status information to capturing traffic and scanning for available networks, the ‘airport’ command is a versatile tool for wireless network management. By exploring the different use cases of the command presented in this article, users can leverage its capabilities to troubleshoot network issues, analyze wireless traffic, and connect to the most suitable Wi-Fi network.

Related Posts

How to use the command ogr2ogr (with examples)

How to use the command ogr2ogr (with examples)

The ogr2ogr command is a powerful tool for converting geospatial vector data between different file formats.

Read More
How to use the command 'extrace' (with examples)

How to use the command 'extrace' (with examples)

The ’extrace’ command is a tool for tracing ’exec()’ calls in a program.

Read More
Using systemd-delta (with examples)

Using systemd-delta (with examples)

Introduction The systemd-delta command is a useful tool that allows you to find overridden systemd-related configuration files in your system.

Read More