Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Port scanning with Nmap
📖 Scenario: You are a network administrator who needs to check which ports are open on a server to ensure security and proper service operation.
🎯 Goal: Learn how to perform basic port scanning using the nmap tool to identify open ports on a target machine.
📋 What You'll Learn
Understand what a port is and why scanning ports is useful
Use nmap to scan a specific IP address
Use nmap to scan a range of ports
Interpret the basic output of nmap scans
💡 Why This Matters
🌍 Real World
Network administrators and cybersecurity professionals use port scanning to check which services are accessible on a server and to identify potential security risks.
💼 Career
Understanding how to perform and interpret port scans is essential for roles in network security, system administration, and ethical hacking.
Progress0 / 4 steps
1
Set up the target IP address
Create a variable called target_ip and set it to the string "192.168.1.1", which represents the IP address of the server you want to scan.
Cybersecurity
Hint
The IP address should be a string assigned to the variable target_ip.
2
Set up the port range to scan
Create a variable called port_range and set it to the string "1-1000", which defines the range of ports you want to scan on the target IP.
Cybersecurity
Hint
The port range should be a string assigned to the variable port_range.
3
Write the Nmap scan command
Create a variable called scan_command and set it to the string that runs nmap with the -p option for ports, scanning the port_range on the target_ip. Use the format: "nmap -p {port_range} {target_ip}" with f-string syntax.
Cybersecurity
Hint
Use an f-string to insert port_range and target_ip into the command string.
4
Explain the purpose of the scan command
Add a comment above the scan_command variable explaining that this command will scan ports 1 to 1000 on the target IP address to find which ports are open.
Cybersecurity
Hint
The comment should clearly state the purpose of the scan_command.
Practice
(1/5)
1. What is the primary purpose of using nmap in cybersecurity?
easy
A. To find open ports on a network device
B. To encrypt network traffic
C. To create firewalls
D. To monitor user activity
Solution
Step 1: Understand what port scanning means
Port scanning is the process of checking which ports on a device are open and listening for connections.
Step 2: Identify Nmap's role
Nmap is a tool designed to perform port scanning to find open ports and services on devices.
Final Answer:
To find open ports on a network device -> Option A
Quick Check:
Port scanning = Finding open ports [OK]
Hint: Nmap scans ports to find open network services [OK]
Common Mistakes:
Confusing port scanning with encryption
Thinking Nmap creates firewalls
Assuming Nmap monitors user activity
2. Which of the following is the correct basic syntax to scan a single IP address using Nmap?
easy
A. nmap -open 192.168.1.1
B. nmap scan 192.168.1.1
C. nmap --check 192.168.1.1
D. nmap -sS 192.168.1.1
Solution
Step 1: Recall Nmap command structure
Nmap commands start with 'nmap' followed by options and then the target IP.
Step 2: Identify correct option for scanning
The '-sS' option is a common scan type (TCP SYN scan) and is valid syntax.
Hint: Use 'nmap -sS <IP>' for a basic TCP SYN scan [OK]
Common Mistakes:
Using 'scan' as a command option
Using invalid options like '-open' or '--check'
Omitting the scan type option
3. What will be the result of running nmap -p 22,80 192.168.0.10?
medium
A. Scan ports 22 and 80 on 192.168.0.10
B. Scan all ports on 192.168.0.10
C. Scan ports 22 to 80 on 192.168.0.10
D. Scan only port 80 on 192.168.0.10
Solution
Step 1: Understand the '-p' option in Nmap
The '-p' option specifies which ports to scan. Comma-separated values mean specific ports.
Step 2: Analyze the ports listed
Ports 22 and 80 are explicitly listed, so only these two ports will be scanned.
Final Answer:
Scan ports 22 and 80 on 192.168.0.10 -> Option A
Quick Check:
'-p 22,80' means scan ports 22 and 80 [OK]
Hint: Comma lists in '-p' scan only those ports [OK]
Common Mistakes:
Assuming '-p 22,80' scans all ports
Thinking it scans a range from 22 to 80
Ignoring the port list format
4. Identify the error in this Nmap command: nmap -p 80-22 192.168.1.5
medium
A. IP address format is incorrect
B. Port range is reversed; should be 22-80
C. Missing scan type option
D. No error; command is correct
Solution
Step 1: Check port range syntax
Port ranges must be in ascending order, e.g., 22-80, not 80-22.
Step 2: Verify other parts of the command
The IP address format is correct, and scan type is optional; default scan works.
Final Answer:
Port range is reversed; should be 22-80 -> Option B
Quick Check:
Port ranges must ascend, not descend [OK]
Hint: Port ranges must go from smaller to larger number [OK]
Common Mistakes:
Using descending port ranges
Thinking IP format is wrong
Believing scan type is always required
5. You want to scan a network range from 192.168.1.1 to 192.168.1.254 for open HTTP ports (port 80) only. Which Nmap command should you use?
hard
A. nmap -p 80 192.168.1.0-254
B. nmap -p 80 192.168.1.1/24
C. nmap -p 80 192.168.1.1-192.168.1.254
D. nmap -p 80 192.168.1.0/24
Solution
Step 1: Understand how to specify IP ranges in Nmap
Nmap accepts explicit ranges like '192.168.1.1-192.168.1.254' to scan all addresses in that range.
Step 2: Check port and target correctness
Port 80 is specified correctly with '-p 80'. The range '192.168.1.1-192.168.1.254' covers all hosts from .1 to .254.
Step 3: Evaluate other options
nmap -p 80 192.168.1.0-254 scans from 192.168.1.0 to 192.168.1.254, including the unwanted network address .0. nmap -p 80 192.168.1.1/24 uses CIDR /24 which scans the entire subnet (.0 to .255). nmap -p 80 192.168.1.0/24 scans the entire subnet including .0 and .255.
Final Answer:
nmap -p 80 192.168.1.1-192.168.1.254 -> Option C
Quick Check:
Explicit IP range with '-p 80' = nmap -p 80 192.168.1.1-192.168.1.254 [OK]
Hint: Use full IP range for precise scanning [OK]
Common Mistakes:
Using shorthand range 192.168.1.0-254 (includes .0)