Nmap, Wireshark, and tcpdump are helpful tools for troubleshooting your network. This article shows you how to use them with a real-world example, because when you're trying to learn a new technology or technique, sometimes the best way is to walk through a scenario.
Trouble begins
In this scenario, a business analyst had administrative privileges on all network devices (routers, switches, servers, and clients). Unfortunately, this individual did not have a solid understanding of these devices or their services, such as firewalls and packet filters, logs, or routing. In my role, I inherited this environment and was told to accept the fact that non-administrators had administrative privileges.
A client device sat on one internal segment, and a database server resided on another. A router with strict packet filtering rules sat between the two segments. The rules were ad hoc and not in a terribly logical order, and the relevant application communicated between the client and server using non-standard ports. I was the only administrator in the company, and as luck would have it, I'd taken the day off.
The analyst decided there was a problem with the router's filter and began making changes. The analyst did not back up the original filter configuration and kept no record of the changes. The analyst made multiple changes until they became frustrated and sent me an email saying, "I don't know what is wrong. I don't know what I did. Now it doesn't work. Fix it!"
This troubleshooting opportunity arose from a real situation I faced as an administrator. Many mistakes were made that allowed this failure to occur in the first place.
Choose your tools
I could have taken several approaches to re-establish connectivity. I decided to use Nmap, Wireshark, and tcpdump to help identify what changes needed to be made to the filter. The general idea was to determine the ports the application expects to use and compare them against the ports the router permits through the interface.
You can use the following steps if you find yourself in the same situation.
1. Scan the router
One logical troubleshooting step is to identify the available connections. Begin by scanning both sides of the router to document the open ports. Nmap is an excellent tool for this job.
Run the scan from each segment against the interface in the router connected to that segment. Save the scan results, then compare the configuration of the filter against the scan results. If the two interfaces have the addresses 192.168.1.1 and 192.168.2.1, the commands are:
$ sudo nmap 192.168.1.1
$ sudo nmap 192.168.2.1There may be more than just two interfaces in the router, so conduct any additional scans necessary to ensure the filters are not blocking (or permitting) the wrong traffic. This is a great opportunity to understand exactly how the router is configured. Use the -oN option to cause Nmap to write the results to a file.
You'll get a list of ports for each interface on the router. Next, find out what ports the application expects to see open. The idea is to compare what ports the application wants to use against what ports it is allowed to use on the router.
2. Intercept communications
Another way to find out what destination ports the application expects to see is by capturing network traffic in each segment. The capture on the client side of the router displays packets addressed to the remote server's IP address. Recall, however, that a port number also gets exposed in the packet sniffer's output. That's the data you're trying to collect.
Use either tcpdump or Wireshark to accomplish this. The following sections document both tools.
Using tcpdump
You can use tcpdump to intercept traffic originating from the client computer and destined for the remote server at 192.168.2.100. The packet header displays the destination port and shows what IP address and port number the traffic needs to use. This can be compared against the existing filter rules as seen on the device and through a Nmap scan. Remember, this capture occurs on the client segment.
$ tcpdump dst 192.168.2.100The capture displays where the traffic is trying to go. But how can tcpdump display whether the traffic is getting through the router and doing so on the correct interface?
[ Download the checklist Considerations for implementing DevSecOps practices. ]
Use tcpdump on the server side of the router to capture traffic addressed to the server. Ideally, the captures on each side of the router should be the same; what's sent from one side should be passed through to the other side. Of course, the problem to resolve is that this is failing to happen. The capture on the server side displays what traffic is getting through—and you already know that the proper traffic is not arriving. Comparing what's sent on one side against what's received on the other side narrows down what traffic is filtered and therefore identifies the rules to edit.
Use the same capture (destination IP) on this side of the router:
$ tcpdump dst 192.168.2.100Output the tcpdump results to files by using the -w {filename} command. Read the .pcap files tcpdump produces by using the -r option with tcpdump or Wireshark.
Using Wireshark
You can use Wireshark instead of tcpdump, if you want. Either tool can handle the job, and sometimes Wireshark is a little easier to work with. The process is the same.
First, capture traffic on the client side of the router. Next, capture traffic on the server side. Use a display filter in Wireshark to view the packets with the server's IP address as the destination (This process basically duplicates the steps from the tcpdump example, just with a different tool.)
Compare the two captures. The port numbers embedded in the client computer's packets are of particular interest. These port numbers indicate the ports the client expects to communicate on. In theory, the server side should show the same packets, but again, that's exactly the failure you're managing.
3. Check the router's firewall settings
Another way of confirming traffic flow is by specifically checking the ports from outside the router. Nmap to the rescue, again! The -sA option displays the port status of the destination machine.
The Nmap syntax for checking firewall status is fairly straightforward:
$ nmap -sA 192.168.2.100Feel free to redirect the output to a file.
Here are the more common states reported by Nmap:
- Open: Port accepts inbound connections
- Closed: No application is listening on the port
- Filtered: Packet filtering prevents Nmap from determining whether a service is listening
- Unfiltered: Port is accessible but Nmap cannot determine port information
Preventing a recurrence
After troubleshooting the problem, we endeavored to prevent a recurrence by making it clear to the analyst that only the network administrator is allowed to make configuration changes. I also changed the administrative password on the network devices to something only I knew.
Using a packet sniffer to see what traffic gets sent from a source computer and comparing the output to the traffic captured on the other side of the router helps narrow packet filtering configuration issues, allowing you to correct or update rules as necessary. A port scan provides a second way of seeing what the router's configuration looks like from the network segments, which is useful for doing a comparison against the filters' current configuration and the expected configuration.
저자 소개
Damon Garn owns Cogspinner Coaction, LLC, a technical writing, editing, and IT project company based in Colorado Springs, CO. Damon authored many CompTIA Official Instructor and Student Guides (Linux+, Cloud+, Cloud Essentials+, Server+) and developed a broad library of interactive, scored labs. He regularly contributes to Enable Sysadmin, SearchNetworking, and CompTIA article repositories. Damon has 20 years of experience as a technical trainer covering Linux, Windows Server, and security content. He is a former sysadmin for US Figure Skating. He lives in Colorado Springs with his family and is a writer, musician, and amateur genealogist.
유사한 검색 결과
Slash VM provisioning time on Red Hat Openshift Virtualization using Red Hat Ansible Automation Platform
Red Hat Ansible Automation Platform: Measuring Business Impact with Dashboard and Analytics
Technically Speaking | Taming AI agents with observability
How Should We Handle Failure? | Compiler
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
가상화
온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래