Red Hat Enterprise Linux Diagnostics and Troubleshooting
Install Wireshark and use it to capture, filter, and inspect network packets. You also use tcpdump to perform similar functions in a textual environment.
Outcomes
You should be able to capture, filter, and inspect network packets with Wireshark and tcpdump.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
[student@workstation ~]$ lab start network-traffic
Instructions
As the
studentuser on theworkstationsystem, switch to therootuser.[student@workstation ~]$
sudo -i[sudo] password for student:student[root@sworkstation ~]#Install the Wireshark package.
[root@workstation ~]#
yum install wireshark...output omitted... Is this ok [y/N]:y...output omitted... Complete!Open Wireshark and configure it to capture packets on all network interfaces.
As the
rootuser, open Wireshark to run as a background process.[root@workstation ~]#
wireshark &On the
Welcome to Wiresharkpage, in the upper right of theCapturesection, selectAll interfaces shownfrom the list.In the center of the
Capturesection, clickanyfrom the interfaces list.From the menu, click , or type Ctrl+E to start the packet capture.
As the
rootuser on theworkstationmachine, open a terminal window and generate network traffic.Use the
pingcommand to send ICMP requests toservera.[root@workstation ~]#
ping -c 5 servera.lab.example.comUse the
chronyc ntpdatacommand to generate NTP traffic that is specific to theclassroomserver.[root@workstation ~]#
chronyd -Q 'server classroom.example.com iburst'Open
Firefoxand browse http://materials.example.com to generate HTTP network traffic.From the menu, click , or type Ctrl+E, to stop the packet capture.
Perform simple filter and inspection routines on the captured network traffic.
Filter the packets for ICMP traffic. In the field, type
icmp. Press Enter. From the middle pane, click any of the right-pointing arrows to inspect the different packet header and data values.Filter the packets for NTP traffic. In the field, type
ntp. Press Enter.Filter the packets for HTTP traffic. In the field, type
http. Press Enter. From the top pane, right-click any of the HTTP packets, and then select to display the stream content in a more readable format. Messages from the HTTP client are displayed in red. Responses from the HTTP server are displayed in blue.
Save the captured packet data for later analysis.
From the menu, click , or type Ctrl+S to open the window. From the list, select the
rootuser's home directory. In the field, typepractice. Leave as the selected type in the field. Click .Confirm that the
practice.pcapngdata file exists.[root@workstation ~]#
ls practice*practice.pcapng [root@workstation ~]#file practice*practice.pcapng: pcap-ng capture file - version 1.0Close Wireshark. From the menu, click .
As the
studentuser on theworkstationmachine, open another terminal window. Open the preconfiguredrh342-practice.tcpdumpcapture file in Wireshark.As the
studentuser on theworkstationmachine, open Wireshark from the desktop. Click in the upper left of the desktop. In the field, in the top center of the desktop, typewireshark. Click .Open the capture file. From the menu, click , or type Ctrl+O to open the window. Browse and select the
rh342-practice.tcpdumpfile. Click .Filter the captured data so that only SMTP packets are displayed. In the field, type
smtp. Press Enter.Inspect the content of the network packets. In the middle pane, click any of the right-pointing triangles to expand different parts of the network packet.
In the top pane, right-click any packet in the SMTP exchange, and then select to display the stream content in a more readable format. Messages from the SMTP server are displayed in blue and messages from the SMTP client are displayed in red.
You should see text that reads "GOLD RING HAS BEEN CAUGHT", which is the first line in the body of the mail message.
Close Wireshark. From the menu, click .
Capture and display network traffic, which requires
rootuser access.As the
studentuser on theworkstationmachine, log in to theserverbmachine and switch to therootuser.[student@workstation ~]$
ssh student@serverb...output omitted... [student@serverb ~]$sudo -i[sudo] password for student:student[root@serverb ~]#Verify that the
tcpdumppackage is installed.[root@serverb ~]#
rpm -q tcpdumptcpdump-4.9.3-1.el8.x86_64Start the
tcpdumputility on theserverbmachine so that it captures network traffic for theserveramachine.[root@serverb ~]#
tcpdump 'ip host servera'dropped privs to tcpdump tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytesFrom a separate terminal window, log in as the
studentuser on theserveramachine.[student@workstation ~]$
ssh student@servera[student@servera ~]$Generate ICMP network traffic that is addressed to the
serverbmachine.[student@servera ~]$
ping -c 3 serverbPING serverb.lab.example.com (172.25.250.11) 56(84) bytes of data. 64 bytes from serverb.lab.example.com (172.25.250.11): icmp_seq=1 ttl=64 time=0.060 ms 64 bytes from serverb.lab.example.com (172.25.250.11): icmp_seq=2 ttl=64 time=0.052 ms 64 bytes from serverb.lab.example.com (172.25.250.11): icmp_seq=3 ttl=64 time=0.055 ms --- serverb.lab.example.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2047ms rtt min/avg/max/mdev = 0.052/0.055/0.060/0.009 msFrom the
serverbterminal window, view thetcpdumpoutput that is displayed on theserverbmachine.22:53:20.038855 IP servera.lab.example.com > serverb.lab.example.com: ICMP echo request, id 1610, seq 1, length 64 22:53:20.038963 IP serverb.lab.example.com > servera.lab.example.com: ICMP echo reply, id 1610, seq 1, length 64 22:53:21.045671 IP servera.lab.example.com > serverb.lab.example.com: ICMP echo request, id 1610, seq 2, length 64 22:53:21.045736 IP serverb.lab.example.com > servera.lab.example.com: ICMP echo reply, id 1610, seq 2, length 64 22:53:22.069693 IP servera.lab.example.com > serverb.lab.example.com: ICMP echo request, id 1610, seq 3, length 64 22:53:22.069752 IP serverb.lab.example.com > servera.lab.example.com: ICMP echo reply, id 1610, seq 3, length 64
End the
tcpdumppacket capture on theserverbmachine.Ctrl+C6 packets captured 6 packets received by filter 0 packets dropped by kernel
Capture incoming network traffic for a specific port. Save the captured packets to a file for later analysis.
Start the
tcpdumputility on theserverbmachine so that it captures HTTP traffic. Save the captured network packets to thehttp-test.tcpdumpfile.[root@serverb ~]#
tcpdump -w http-test.tcpdump 'port 80'dropped privs to tcpdump tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytesIn the
serveraterminal window, display the web content from theserverbmachine.[student@servera ~]$
curl http://serverb.lab.example.comSERVERB is providing web content.In the
serverbterminal window, interrupt thetcpdumputility to stop the packet capture.Ctrl+C12 packets captured 12 packets received by filter 0 packets dropped by kernel
Display the captured network traffic.
In the
serverbterminal window, use thetcpdumputility to display the captured network traffic. If-ris the only option, then only packet header information is displayed by default.FILENAME[root@serverb ~]#
tcpdump -r http-test.tcpdumpreading from file http-test.tcpdump, link-type EN10MB (Ethernet) dropped privs to tcpdump 20:42:16.374181 IP servera.lab.example.com.60408 > serverb.lab.example.com.http: Flags [S], seq 2599241697, win 29200, options [mss 1460,sackOK,TS val 3400465832 ecr 0,nop,wscale 7], length 0 20:42:16.374284 IP serverb.lab.example.com.http > servera.lab.example.com.60408: Flags [R.], seq 0, ack 2599241698, win 0, length 0 20:43:31.505131 IP servera.lab.example.com.60412 > serverb.lab.example.com.http: Flags [S], seq 3593487441, win 29200, options [mss 1460,sackOK,TS val 3400540964 ecr 0,nop,wscale 7], length 0 20:43:31.505208 IP serverb.lab.example.com.http > servera.lab.example.com.60412: Flags [S.], seq 1455608366, ack 3593487442, win 28960, options [mss 1460,sackOK,TS val 1722155038 ecr 3400540964,nop,wscale 7], length 0 ...output omitted...Display incoming packets that originate only from the
serveramachine. Display the packets in hexadecimal format.[root@serverb ~]#
tcpdump -x -r http-test.tcpdump 'src servera'reading from file http-test.tcpdump, link-type EN10MB (Ethernet) dropped privs to tcpdump 20:42:16.374181 IP servera.lab.example.com.60408 > serverb.lab.example.com.http: Flags [S], seq 2599241697, win 29200, options [mss 1460,sackOK,TS val 3400465832 ecr 0,nop,wscale 7], length 0 0x0000: 4500 003c 8b66 4000 4006 630c ac19 fa0a 0x0010: ac19 fa0b ebf8 0050 9aed 47e1 0000 0000 0x0020: a002 7210 f236 0000 0204 05b4 0402 080a 0x0030: caae fda8 0000 0000 0103 0307 20:43:31.505131 IP servera.lab.example.com.60412 > serverb.lab.example.com.http: Flags [S], seq 3593487441, win 29200, options [mss 1460,sackOK,TS val 3400540964 ecr 0,nop,wscale 7], length 0 0x0000: 4500 003c d7e6 4000 4006 168c ac19 fa0a 0x0010: ac19 fa0b ebfc 0050 d630 4451 0000 0000 0x0020: a002 7210 4c78 0000 0204 05b4 0402 080a 0x0030: cab0 2324 0000 0000 0103 0307 ...output omitted...Display incoming packets that originate only from the
serveramachine. Display the packets in hexadecimal and ASCII formats.[root@serverb ~]#
tcpdump -X -r http-test.tcpdump 'src servera'reading from file http-test.tcpdump, link-type EN10MB (Ethernet) dropped privs to tcpdump 20:42:16.374181 IP servera.lab.example.com.60408 > serverb.lab.example.com.http: Flags [S], seq 2599241697, win 29200, options [mss 1460,sackOK,TS val 3400465832 ecr 0,nop,wscale 7], length 0 0x0000: 4500 003c 8b66 4000 4006 630c ac19 fa0a E..<.f@.@.c..... 0x0010: ac19 fa0b ebf8 0050 9aed 47e1 0000 0000 .......P..G..... 0x0020: a002 7210 f236 0000 0204 05b4 0402 080a ..r..6.......... 0x0030: caae fda8 0000 0000 0103 0307 ............ 20:43:31.505131 IP servera.lab.example.com.60412 > serverb.lab.example.com.http: Flags [S], seq 3593487441, win 29200, options [mss 1460,sackOK,TS val 3400540964 ecr 0,nop,wscale 7], length 0 0x0000: 4500 003c d7e6 4000 4006 168c ac19 fa0a E..<..@.@....... 0x0010: ac19 fa0b ebfc 0050 d630 4451 0000 0000 .......P.0DQ.... 0x0020: a002 7210 4c78 0000 0204 05b4 0402 080a ..r.Lx.......... 0x0030: cab0 2324 0000 0000 0103 0307 ..$........ 20:43:31.505357 IP servera.lab.example.com.60412 > serverb.lab.example.com.http: Flags [.], ack 1455608367, win 229, options [nop,nop,TS val 3400540964 ecr 1722155038], length 0 0x0000: 4500 0034 d7e7 4000 4006 1693 ac19 fa0a E..4..@.@....... 0x0010: ac19 fa0b ebfc 0050 d630 4452 56c2 d22f .......P.0DRV../ 0x0020: 8010 00e5 4c70 0000 0101 080a cab0 2324 ....Lp........$ 0x0030: 66a6 001e f... 20:43:31.505391 IP servera.lab.example.com.60412 > serverb.lab.example.com.http: Flags [P.], seq 0:87, ack 1, win 229, options [nop,nop,TS val 3400540964 ecr 1722155038], length 87: HTTP: GET / HTTP/1.1 0x0000: 4500 008b d7e8 4000 4006 163b ac19 fa0a E.....@.@..;.... 0x0010: ac19 fa0b ebfc 0050 d630 4452 56c2 d22f .......P.0DRV../ 0x0020: 8018 00e5 4cc7 0000 0101 080a cab0 2324 ....L.........#$ 0x0030: 66a6 001e 4745 5420 2f20 4854 5450 2f31 f...GET./.HTTP/1 0x0040: 2e31 0d0a 486f 7374 3a20 7365 7276 6572 .1..Host:.server 0x0050: 622e 6c61 622e 6578 616d 706c 652e 636f b.lab.example.co 0x0060: 6d0d 0a55 7365 722d 4167 656e 743a 2063 m..User-Agent:.c 0x0070: 7572 6c2f 372e 3631 2e31 0d0a 4163 6365 url/7.61.1..Acce 0x0080: 7074 3a20 2a2f 2a0d 0a0d 0a pt:./.... ...output omitted...Copy the captured HTTP data to the
workstationmachine for further analysis. Use Wireshark on theworkstationmachine to view the captured HTTP network traffic. Follow the TCP stream to view the HTTP exchange in a more readable format.[root@serverb ~]#
scp http-test.tcpdump student@workstation:...output omitted... student@workstation's password:studenthttp-test.tcpdump 100% 1395 1.5MB/s 00:00Return to
workstationas thestudentuser.[root@serverb ~]#
exit[student@serverb ~]$exit[student@workstation ~]$