Networking/Computing Tips/Tricks

If you are like me, you count on the Internet to help with how to's especially when using Linux.  That said, sometimes the information can be contradicting or confusing.  This article shows that there are three ways to put your Wi-Fi adapter into monitor mode in Linux!  Three!  So let's jump in.

In this article I am using Kali Linux (which is Debian based).

1. Using iw

Start by making sure the system recognizes the Wi-Fi interface:

sudo iw dev

You should get something like this:

2019 02 18 9 20 10

The output tells us that the Wi-Fi interface is called "wlan0" and in my case the MAC address is "b2:79:47:a2:a0:54".  We also see that the interface is in "managed" mode, meaning it is operating as a station (the other options here would be monitor or ad-hoc or master)

There are three commands to put the interface into monitor mode that turn off the interface so we can change its settings, set it into monitor mode, then tuen the interface back up:

sudo ip link set wlan0 down
sudo iw wlan0 set monitor none
sudo ip link set wlan0 up

2019 02 18 9 34 11

You can now verify the type has been changed with that same 'sudo iw dev' command:

2019 02 18 9 35 44

We can see the type is now monitor, and we can also see what channel we are on.

You could now start up a tool like Wireshark and capture on the interface.  Wireshark will also allow you (using the Wireless tool bar that is turned on from the View menu) to change channels.

Once done sniffing the Wi-Fi you turn off monitor mode with these three commands:

sudo ip link set wlan0 down
sudo iw wlan0 set type managed
sudo ip link set wlan0 up

2. Using iwconfig

The second way to do this is with iwconfig.  Let's start by checking for the interface name:

sudo iwconfig

2019 02 18 9 43 45

 We see the name of the interface "wlan0" and that it is in "Mode: Managed".  Note that the MAc address is not provided with this command.  If you want that you need to input the "ifconfig" command:

2019 02 18 9 46 16

To enable monitor mode you once again have to turn the interface off, change its mode, then bring it back up again:

sudo ifconfig wlan0 down
sudo iwconfig wlan0 mode monitor
sudo ifconfig wlan0 up

2019 02 18 9 50 58

We can see that after looking at the "iwconfig" that the mode is changed to Monitor.

As stated previously, you can now use a tool to look at the Wi-Fi packets.

To return the interface to normal managed mode:

sudo ifconfig wlan0 down
sudo iwconfig wlan0 mode managed
sudo ifconfig wlan0 up

3. Using airmon-ng

 This method presumes you have the tool installed.  To test this, use the following command:

sudo airmon-ng

2019 02 18 9 55 59

We see the "wlan0" interface.

If this command does not work, Linux will suggest you install the aircrack-ng tool with the following command:

sudo apt-get install aircrack-ng

which we suggest you do!

The next thing we can do is use airmon-ng to check for interfering processes. This is done with the following command:

sudo airmon-ng check

2019 02 18 10 00 58

To disable these processes use the following command:

sudo airmon-ng check kill

2019 02 18 10 02 22

Ok - now let's put the interface into monitor mode:

sudo airmon-ng start wlan0

2019 02 18 10 04 24

What has happenned is a little different than our prior two methods.  The tool has created a new interface called "wlan0mon".

So if we look at our interfaces using the "ifconfig" or "iwconfig" commands, we see the "wlan0mon" interface:

2019 02 18 10 07 38

2019 02 18 10 10 10

Now when you start your packet capture tool like Wireshark, you will select that interface to capture packets on.

To return the interface to normal, we need to disable monitor mode as follows:

sudo airmon-ng stop wlan0mon

2019 02 18 10 11 06

A note here - if you need to retart the network manager use "sudo systemctl start NetworkManager".

We hope that was fun and informative.

Comments powered by CComment

Find by Tag

4G Networks 5G Networks 6LoWLAN 6LoWPAN 802.11 802.11ah 802.11ax 802.11ay 802.11az Addressing Analysis Ansible Architecture ARP AToM Baseline BGP Bloom's Taxonomy Broadband Cable cat CellStream Cellular Central Office Cheat Sheet Chrome Cisco Cloud CMD Coloring Rules Computer Consulting Customer Support Data Center Data Networking DHCPv6 DNS Docker Documentation Dublin-Traceroute dumpcap ECMP Ethernet Ethics Field Operations Fragmentation G-MPLS GeoIP Git GNS3 Google GQUIC Hands-On History Home Network ICMP ICMPv6 IEEE 802.11p IEEE 802.15.4 Interface Control Internet IoT IPsec IPv4 IPv6 IRINN IS-IS L2VPN L3VPN LDP Linux LLN LoL M-BGP MAC Macro Microsoft mininet Monitoring MPLS mtr MTU Multicast Name Resolution Netcat Netmiko NetMon netsh Networking Network Science nmap Npcap NSE Observations Online School OpenFlow OSPF OSPFv2 OSPFv3 OSX OTT Paris-Traceroute Parrot PIM PMTU Policy POTS POTS to Pipes PPP Profile Programming Project Management PW3E Python QoS QUIC Remote Desktop Requirements Resume RIP Routing RPL RSVP Rural SDN Security Service Provider Small Business SONET Speed SS7 SSH SSL Subnetting SYSCTL T-Shark TCP TCP/IP Telco Telecom 101 Telecommunications Telephone termshark Testing TLS Tools Traceroute Traffic Engineering Training Travel Tunnel Ubuntu Utility Video Virtualbox Virtualization VoIP VRF VXLAN WEP Wi-Fi Wi-Fi 4 Wi-Fi 5 Wi-Fi 6 Windows Winpcap Wireless Wireless 5G Wireshark Wireshark Tip WLAN WPA2 Writing Zenmap ZigBee

Twitter Feed