4.3.4 Lab - Linux Servers - ILM
4.3.4 Lab - Linux Servers - ILM
Objectives
In this lab, you will use the Linux command line to identify servers running on a given computer.
Part 1: Servers
Part 2: Using Telnet to Test TCP Services
Recommended Equipment
CyberOps Workstation virtual machine
Note: This lab can be done using the virtual machine created in a previous lab.
Instructions
Part 1: Servers
Servers are essentially programs written to provide specific information upon request. Clients, which are also
programs, reach out to the server, place the request, and wait for the server response. Many different client-
server communication technologies can be used, with the most common being IP networks. This lab focuses
on IP network-based servers and clients.
2018 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 1 of 7 www.netacad.com
Lab - Linux Servers
Why was it necessary to run ps as root (prefacing the command with sudo)?
Type your answers here.
Some processes do not belong to the analyst user and may not be displayed if ps was executed
as analyst, which is a regular user account.
b. In Linux, programs can also call other programs. The ps command can also be used to display such
process hierarchy. Use –ejH options to display the currently running process tree after starting the nginx
webserver with elevated privileges.
Note: The process information for the nginx service is highlighted. Your PID values will be different.
[analyst@secOps ~]$ sudo /usr/sbin/nginx
[analyst@secOps ~]$ sudo ps –ejH
[sudo] password for analyst:
PID PGID SID TTY TIME CMD
1 1 1 ? 00:00:00 systemd
167 167 167 ? 00:00:01 systemd-journal
193 193 193 ? 00:00:00 systemd-udevd
209 209 209 ? 00:00:00 rsyslogd
210 210 210 ? 00:01:41 java
212 212 212 ? 00:00:01 ovsdb-server
213 213 213 ? 00:00:00 start_pox.sh
224 213 213 ? 00:01:18 python2.7
214 214 214 ? 00:00:00 systemd-logind
216 216 216 ? 00:00:01 dbus-daemon
221 221 221 ? 00:00:05 filebeat
239 239 239 ? 00:00:05 VBoxService
287 287 287 ? 00:00:00 ovs-vswitchd
2018 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 2 of 7 www.netacad.com
Lab - Linux Servers
Through indentation.
c. As mentioned before, servers are essentially programs, often started by the system itself at boot time.
The task performed by a server is called a service. In such fashion, a web server provides web services.
The netstat command is a great tool to help identify the network servers running on a computer. The
power of netstat lies on its ability to display network connections.
Note: Your output maybe different depending on the number of open network connections on your VM.
In the terminal window, type netstat.
[analyst@secOps ~]$ netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost.localdo:48746 localhost.local:wap-wsp ESTABLISHED
tcp 0 0 localhost.localdo:48748 localhost.local:wap-wsp ESTABLISHED
tcp6 0 0 localhost.local:wap-wsp localhost.localdo:48748 ESTABLISHED
tcp6 0 0 localhost.local:wap-wsp localhost.localdo:48746 ESTABLISHED
tcp6 0 0 localhost.local:wap-wsp localhost.localdo:48744 ESTABLISHED
tcp6 0 0 localhost.localdo:48744 localhost.local:wap-wsp ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 3 [ ] DGRAM 8472 /run/systemd/notify
unix 2 [ ] DGRAM 8474 /run/systemd/cgroups-
agent<some output omitted>
As seen above, netstat returns lots of information when used without options. Many options can be used
to filter and format the output of netstat, making it more useful.
2018 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 3 of 7 www.netacad.com
Lab - Linux Servers
d. Use netstat with the –tunap options to adjust the output of netstat. Notice that netstat allows multiple
options to be grouped together under the same “-“ sign.
The information for the nginx server is highlighted.
[analyst@secOps ~]$ sudo netstat -tunap
[sudo] password for analyst:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
PID/Program name
tcp 0 0 0.0.0.0:6633 0.0.0.0:* LISTEN
257/python2.7
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
395/nginx: master
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
279/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
277/sshd: /usr/bin
tcp6 0 0 :::22 :::* LISTEN
277/sshd: /usr/bin
udp 0 0 192.168.1.15:68 0.0.0.0:*
237/systemd-network
Question:
What is the meaning of the –t, -u, –n, –a and –p options in netstat? (use man netstat to answer)
Type your answers here.
-a: shows both listen and non-listening sockets. -n: use numeric output (no DNS, service port or
username resolution), -p: show the PID of the connection owner process. -t: shows TCP
connections. –u: shows UDP connections
Is the order of the options important to netstat?
Type your answer here.
Based on the netstat output shown in item (d), what is the Layer 4 protocol, connection status, and PID
of the process running on port 80?
Type your answers here.
2018 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 4 of 7 www.netacad.com
Lab - Linux Servers
The process PID 395 is nginx. How could that be concluded from the output above?
Type your answers here.
Based on the last column of line 1, the output shows nginx command line.
What is nginx? What is its function? (Use google to learn about nginx)
Type your answers here.
It means that nginx started process 396 under the http username. This is normal as nginx runs
itself for every client that connects to port 80 TCP.
Why is the last line showing grep 395?
Type your answers here.
2018 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 5 of 7 www.netacad.com
Lab - Linux Servers
Because the grep 395 was used to filter the ps output, when the output was compiled, grep 395
was still running and therefore, it appeared in the list.
<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.16.1</center>
</body>
</html>
Connection closed by foreign host.
Thanks to the Telnet protocol, a clear text TCP connection was established, by the Telnet client, directly
to the nginx server, listening on 127.0.0.1 port 80 TCP. This connection allows us to send data directly to
the server. Because nginx is a web server, it does not understand the sequence of random letters sent to
it and returns an error in the format of a web page.
Why was the error sent as a web page?
Type your answers here.
2018 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 6 of 7 www.netacad.com
Lab - Linux Servers
Nginx is a web server and as such, only speaks the HTTP protocol.
While the server reported an error and terminated the connection, we were able to learn a lot. We learned
that:
1) The nginx with PID 395 is in fact a web server.
2) The version of nginx is 1.16.1.
3) The network stack of our CyberOps Workstation VM is fully functional all the way to Layer 7.
Not all services are equal. Some services are designed to accept unformatted data and will not terminate
if garbage is entered via keyboard. Below is an example of such a service:
c. Looking at the netstat output presented earlier, it is possible to see a process attached to port 22. Use
Telnet to connect to it.
Port 22 TCP is assigned to SSH service. SSH allows an administrator to connect to a remote computer
securely.
Below is the output:
[analyst@secOps ~]$ telnet 127.0.0.1 22
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
SSH-2.0-OpenSSH_8.2
sdfjlskj
Invalid SSH identification string.
Connection closed by foreign host.
Use Telnet to connect to port 68. What happens? Explain.
Type your answers here.
Unable to connect because the connection is refused. Telnet is a TCP-based protocol and will not
be able to connect to UDP ports.
Reflection Questions
1. What are the advantages of using netstat?
Type your answers here.
Netstat allows for an analyst to display all the connections currently present on a computer. Source
and destination addresses, ports, and process IDs can also be displayed, providing a quick overview
of all connections present on a computer.
2. What are the advantages of using Telnet? Is it safe?
Type your answers here.
Yes, as long it is not used as a remote shell. It is perfectly safe to quickly test or gather information
about a given network service.
End of document
2018 - 2024 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 7 of 7 www.netacad.com