How to use the command 'iwconfig' (with examples)
- Linux
- December 25, 2023
The ‘iwconfig’ command allows you to configure and display the parameters of a wireless network interface. It provides information about network settings such as wireless mode, ESSID, frequency, signal strength, and more.
Use case 1: Show the parameters and statistics of all the interfaces
Code:
iwconfig
Motivation: This use case is useful when you want to quickly check the current configuration and statistics of all the wireless network interfaces on your system.
Explanation:
- ‘iwconfig’: This is the command itself to show the parameters and statistics of wireless network interfaces.
Example output:
wlp2s0 IEEE 802.11 ESSID:"MyNetwork"
Mode:Managed Frequency:2.412 GHz Access Point: AB:CD:EF:01:23:45
Bit Rate=54 Mb/s Tx-Power=22 dBm
Retry long limit:7 RTS thr=2347 B Fragment thr:off
Power Management:on
Link Quality=60/70 Signal level=-55 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
Use case 2: Show the parameters and statistics of the specified interface
Code:
iwconfig interface
Motivation: When you have multiple wireless network interfaces on your system, this use case allows you to view the parameters and statistics of a specific interface. This can be helpful for troubleshooting or checking the configuration of a particular wireless interface.
Explanation:
- ‘interface’: Specify the name of the interface you want to view the parameters and statistics for. For example, ’eth0’ or ‘wlp2s0’.
Example output:
wlp2s0 IEEE 802.11 ESSID:"MyNetwork"
Mode:Managed Frequency:2.412 GHz Access Point: AB:CD:EF:01:23:45
Bit Rate=54 Mb/s Tx-Power=22 dBm
Retry long limit:7 RTS thr=2347 B Fragment thr:off
Power Management:on
Link Quality=60/70 Signal level=-55 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
Use case 3: Set the ESSID (network name) of the specified interface
Code:
iwconfig interface new_network_name
Motivation: This use case is helpful when you want to change the network name (ESSID) of a specific wireless interface.
Explanation:
- ‘interface’: Specify the name of the interface you want to set the ESSID for.
- ’new_network_name’: Specify the new network name (ESSID) you want to set for the interface.
Example output: (No output will be shown if the command is successful)
Use case 4: Set the operating mode of the specified interface
Code:
iwconfig interface mode mode_type
Motivation: The operating mode of a wireless interface determines how it functions within a network. This use case allows you to set the operating mode of a specific wireless interface to one of the supported modes.
Explanation:
- ‘interface’: Specify the name of the interface you want to set the operating mode for.
- ‘mode_type’: Specify the operating mode you want to set for the interface. It can be one of the following: ad hoc, Managed, Master, Repeater, Secondary, Monitor, Auto.
Example output: (No output will be shown if the command is successful)
Conclusion:
The ‘iwconfig’ command is a powerful tool for managing and configuring wireless network interfaces. It provides a range of options to view and modify network settings. By understanding and utilizing the different use cases of this command, you can effectively manage your wireless network interfaces.