Difference between revisions of "Server Basics"

From docwiki
Jump to: navigation, search
(CLI Tools for Opening Connections)
Line 35: Line 35:
 
== CLI Tools for Opening Connections ==
 
== CLI Tools for Opening Connections ==
   
  +
The classical tool to open a TCP connection is '''telnet'''. Telnet was initially used in the same way we use SSH today - but it had no encryption. But instead of connection to a telnet server port the telnet tool can connect to any TCP port.
x
 

Revision as of 19:21, 29 March 2020


Motivation

Linux is an ideal operating sytstem for servers. From a small Raspberry Pi that controls some IoT devices to the big data centers. Linux is everywhere. Here we will only cover some of the more common server services. You can also learn some basics that are useful for many server applications.

Listen Sockets

When programs connect via the network, they use the system libraries to open so called sockets. Sockets are like similar to files: You can open and close them and read and write from them. For services where other clients connect to we have so called listen sockets.

Linux offers so called unix domain sockets which are look like files but are actually connections between programs. Similar to that there are named pipes which are can be even opened with regular file operations. But these 2 are only useful for communication between processes on the same machine.

For network connections there are network sockets. A server chooses to open a network port and tells the operation system that it wants to listen there for incoming calls. Once the kernel receives packets form the network that the connection is established and the server can communicate with the other end. Most servers then fork off some process that handles the communication and the main program continues to listen for additional connections.

For IP packets there are 16bit port numbers and the most used protocols are TCP (for end-to-end connections where the server program only wants a data-stream and is not interested in the details of the connection - e.g. a weeb server) and UDP which consists of small datagram packets. The server is responsible there to deal with issues like lost packets and even packets received in different order.

Port Number Protocol Service
22 TCP SSH - secure shell
25 TCP SMTP - sending mails between server
80 TCP HTTP - un-encrypted web.
443 TCP HTTPS - encrypted web
53 UDP DNS - Domain Name Service


CLI Tools for Opening Connections

The classical tool to open a TCP connection is telnet. Telnet was initially used in the same way we use SSH today - but it had no encryption. But instead of connection to a telnet server port the telnet tool can connect to any TCP port.