Course contentsShow
← Linux
Lesson 1106 of 1,81910. Network Administration and Kernel StacksFree lesson

Promiscuous Mode and Traffic Capture

Capture raw traffic at the kernel level for advanced security analysis.

In this lesson, you will learn how to bypass standard network filtering to capture raw traffic directly at the kernel level for advanced security analysis.

The Standard Filtering Barrier

By default, your Network Interface Card (NIC) and the Linux kernel network stack are selective. They only pass traffic to the upper layers (like your sockets) if the Ethernet frame destination matches your interface's MAC address or is a broadcast/multicast address. For security auditing or troubleshooting, this is insufficient; you often need to see all packets traversing the wire, even those addressed to other nodes on the local segment.

Enter Promiscuous Mode

Promiscuous mode is a state where the interface is instructed to disable hardware-level address filtering. When a NIC is set to this mode, it passes every frame it receives to the kernel’s network stack, regardless of the destination MAC address.

In Linux, you can toggle this state using ip link. For example, to enable it on eth0:

# Enable promiscuous mode
sudo ip link set eth0 promisc on

# Verify the interface status
ip link show eth0

The Kernel Hook: AF_PACKET

Once the NIC is in promiscuous mode, the raw frames must be delivered to a user-space application (like tcpdump or wireshark). This is handled by the AF_PACKET address family. Unlike standard AF_INET sockets that strip away headers, AF_PACKET sockets allow you to tap directly into the kernel’s data link layer.

When you run a packet capture tool, it opens an AF_PACKET socket and registers a packet hook. The kernel’s networking subsystem then clones the incoming sk_buff (socket buffer) and delivers a copy of the raw frame to your capture application before the protocol-specific processing (like IP stack routing) even occurs. This allows you to inspect the full frame, including Ethernet headers, providing a complete view of the raw traffic for intrusion detection and forensic analysis.

Always remember that promiscuous mode is a "noisy" state that can be detected by network administrators; it is intended for administrative troubleshooting and security visibility rather than covert operations.

Key Takeaway: Promiscuous mode instructs the NIC to bypass MAC address filtering, allowing the kernel to capture all raw frames via AF_PACKET sockets for deep security analysis.