Capture Traffic with -i eth1
In this step, you will learn how to capture network traffic on the eth1 interface using basic Linux commands. The eth1 interface is typically the primary network interface in Linux systems, representing the first Ethernet connection on your machine.
Before capturing traffic, it's important to verify that the interface exists and is active. Network interfaces can be physical (like Ethernet ports) or virtual (like VPN connections). Run this command to check your eth1 interface status:
ip link show eth1
You should see output similar to:
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 00:16:3e:5e:6c:00 brd ff:ff:ff:ff:ff:ff
The UP
status indicates the interface is active. Now we'll use tcpdump
, a fundamental tool for network analysis that lets you see traffic in real-time. This basic capture command will help you understand what's happening on your network:
sudo tcpdump -i eth1 -c 5
Let's break down what this command does:
-i eth1
: Specifies which network interface to monitor (eth1 in this case)
-c 5
: Limits the capture to 5 packets, which is enough for demonstration without flooding your terminal
The output will show packet details including timestamps, source/destination IPs, and protocol information:
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
12:34:56.789012 IP 192.168.1.100.22 > 192.168.1.1.12345: Flags [P.], seq 1:21, ack 1, win 501, length 20
12:34:56.789123 IP 192.168.1.1.12345 > 192.168.1.100.22: Flags [.], ack 21, win 1024, length 0
...
5 packets captured
5 packets received by filter
0 packets dropped by kernel
For more detailed analysis, you'll want to save packets to a file. PCAP files preserve all packet data and can be opened in graphical tools like Wireshark. This command creates a capture file:
sudo tcpdump -i eth1 -c 5 -w ~/project/eth1_capture.pcap
The -w
flag writes packets to eth1_capture.pcap
in your project directory. This binary format maintains all original packet information exactly as it was captured.