{"id":301,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:17","modified_gmt":"2020-08-22T20:26:17","slug":"this-is-the-page-title-toplevel-136","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=301","title":{"rendered":"Network Services"},"content":{"rendered":"\n<title>Network Services<\/title>\n<p>\nIn the discussion above, I used the <command>telnet<\/command> command as an example of one of the programs that\nuse <glossary>TCP<\/glossary>\/<glossary>IP<\/glossary>. However, there are many others which provide additional\nservices such as transferring\nfiles, electronic mail, networking printing, and access to remote filesystems. Other products, such\nas database applications may have one central machine containing all the data and access is gained\nfrom the other machines via TCP\/IP. Often this access is invisible to the user who just sees the &#8220;front end&#8221;\nof the database.\n<\/p>\n<question id=\"\" type=\"mc\" text=\"What pair of terms is typically used when describing pairs of machines when sharing resources?\" \/>\n<p>\nThis configuration, where one machine contains the data or resource that an other machine uses\nis very common in computer networking. The machine with the resource that it is providing to other\nmachines is referred to as the <i>server<\/i>, because it is serving the resource to the other\nmachine. The machine that is using the resource is called the <i>client<\/i>. This model, where one\nmachine is the server and the other is the <glossary>client<\/glossary>\nis referred to as a <glossary>client-server model<\/glossary>.\n<\/p>\n<p>\nAnother common <glossary>network<\/glossary>\nmodel is the <em>peer-to-peer model<\/em>. In this model, there is no one\ncentral machine that has all the resources. Instead, all machines are on equal status. Often times,\nthese two models sort of blend together. In Linux networks, it is possible to have multiple servers,\neach providing many of the same resources. In can also happen that multiple machines all have\nresources that the others need so everyone is acting as both a <glossary>client<\/glossary>\nand a server, similar to\n<glossary>peer-to-peer<\/glossary>, which is common in Microsoft Windows networks.\n<\/p>\n<p>\nOn Linux systems, there are dozens of resources available. Many of which are well-known such as\ntelnet, others, such as ntp are more obscure. Like calling into a large office building with a\ncentral switchboard, our server needs to know what numbers are associated with which programs in\norder to make the proper connection. In the same regard, you need to know what office you want to\nreach before you call. In some cases you can call and say you want a particular extension. In other\ncases, you say you want a particular office. In a office building there is a list of available\n&#8220;services&#8221;, called a phone book. On a Linux system the phone book is the file\n<file type=\"\">\/etc\/services<\/file>.\n<\/p>\n<question id=\"\" type=\"mc\" text=\"Which file contains a list of what services a particular machine may have to offer?\" \/>\n<concept id=\"\" description=\"The \/etc\/services file contains a list of what services a particular machine may have to offer.\" \/>\n<p>\nThe <file type=\"\">\/etc\/services<\/file> file contains a list of what services a particular machine may have to offer.\nThe concept of a <glossary>service<\/glossary> is slightly different than the concept of a resource. A machine may provide\nmany resources in the form of <glossary>login<\/glossary>\nshells that it provides to remote users, however all of them are\naccessing the machine through the one service: telnet.\n<\/p>\n<question id=\"\" type=\"mc\" text=\"What information is contained in the \/etc\/services file?\" \/>\n<p>\nIn addition to what service the machine provides, <file type=\"\">\/etc\/services<\/file> also lists the <glossary>port<\/glossary>. To\nunderstand the idea of a port, think about this as being the telephone number. When I call in to a\nmachine (say using telnet), I am connected to the <command>telnet<\/command> program on the other side through a\nparticular port. This is as if I were calling a large office building with a single switchboard. When I reach that switchboard, I tell the operator which office or person I want to talk to. In the ancient history of telephones, that operator had to make the connection between the incoming line and the office herself.\n<\/p>\n<p>\nA port can also be thought of as the socket that the operator plugs the phone lines into. Like\nin that office building, there may be a set of these sockets, or ports, that are directly connected\nto a specific person (i.e. <glossary>service<\/glossary>). These are <em>well-known<\/em> ports. There may be offices with\ntheir own operator (maybe just a receptionist) who passes the incoming phone call to the right\nperson or may even pick someone themselves to take the call (such as when you call a government\nagency with a generic question and there is no one person responsible for that area).\n<\/p>\n<p>\nOn a Linux system using <glossary>TCP<\/glossary>\/<glossary>IP<\/glossary>, the principle is the same. There are dozens of services that\none can connect to, but only one way into the system, that&#8217;s through your <glossary>network<\/glossary>\ninterface card. In\norder for you to be able to connect to the right service, there has to be something like an operator\nto make the connection for you. This is the program <command>\/etc\/inetd<\/command>. This is the &#8220;Internet Daemon&#8221; and\noften referred to as a &#8220;super server&#8221; since it is inetd&#8217;s responsibility to wait for requests to\naccess the other servers on your system and pass you along.\n<\/p>\n<p>\nLike in our office building, you may know what number you want, that is, which <glossary>port<\/glossary>. When you\nmake the connection to inetd, your process tells it what port you want to connect to and inetd makes\nthe connection.\nOn the other hand, you may have a program that does not have a well-known port. Therefore a new port needs to be defined.\n<\/p>\n<question id=\"\" type=\"mc\" text=\"What process 'listens' for incoming network connections?\" \/>\n<p>\nThe inetd <glossary>daemon<\/glossary>\n&#8220;listens&#8221; for the incoming connections. You can say that it is\nlistening on multiple ports in the sense that it manages all the ports. However,\nit is inetd that makes the connection between the incoming connection and the\nlocal port, and therefore to the local server. This mechanism saves memory since\nyou don&#8217;t need to start up the servers you aren&#8217;t going to use. This is similar\nto having a central switchboard and not requiring every office to have their\nown. You can see how this looks graphically here:\n<\/p>\n<p>\n<a onclick=\"opennew('{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}CURRENT_DIRECTORY{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}{3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}\/inetda.gif',395,523)\" >\n<img loading=\"lazy\" decoding=\"async\" src=\"inetdc.gif\" width=\"523\" height=\"395\" border=\"0\" usemap=\"#inetd_map\">\n<\/a>\n<map name=\"inetd_map\">\n<!-- #$-:Image Map file created by GIMP Imagemap Plugin -->\n<!-- #$-:GIMP Imagemap Plugin by Maurits Rijk -->\n<!-- #$-:Please do not edit lines starting with \"#$\" -->\n<!-- #$VERSION:1.3 -->\n<!-- #$AUTHOR:James Mohr -->\n<area shape=\"RECT\" coords=\"1,167,183,237\" href=\"popup#inetd#Incoming network requests are received by the inetd daemon.\">\n<area shape=\"RECT\" coords=\"183,165,342,234\" href=\"popup#inetd#The inetd daemon determines which service is requested and like a telephone operator connects the requestor to the appropriate service.\">\n<area shape=\"RECT\" coords=\"341,5,524,393\" href=\"popup#inetd#The services that inetd connects to is usually defined in \/etc\/services.\">\n<\/map>\n<p>\n<icaption>Image &#8211; Graphical representation of the inetd daemon (<b>interactive<\/b>)<\/icaption>\n<\/p>\n<question id=\"\" type=\"mc\" text=\"How is inetd normally started?\" \/>\n<question id=\"\" type=\"mc\" text=\"What is inetd's configuration file?\" \/>\n<p>\nNormally, <command>inetd<\/command> is started during system start up from a script under <directory>\/etc\/rc.d<\/directory>. When it starts,\ninetd reads its configuration file (<file type=\"\">\/etc\/inetd.conf<\/file>) to obtain the necessary information to start\nthe various servers. It then builds the logical connection between the server and its respective\nport. Kind of like laying the cable from the central switchboard to the various offices. Technically\nit creates a <glossary>socket<\/glossary>, which is <glossary term=\"bind\">bound<\/glossary> to the port for that server.\n<\/p>\n<p>\nWhen <command>inetd<\/command> gets a connection request (the phone rings) for a connection-based port, it &#8220;accepts&#8221;\nthe incoming call which creates a new <glossary>socket<\/glossary>. That is, there is a logical connection between the incoming request and the server. Inetd can now continue to listen on the original port for addition incoming calls.\n<\/p>\n<question id=\"\" type=\"\" text=\"What does it mean when an entry in \/etc\/inetd.conf has 'wait' in the 'flags' column?\/>\n<p>\nIf the port is <glossary>connection-less<\/glossary> (<glossary>UDP<\/glossary>), the behavior is dependent on entries\nin the <file type=\"\">\/etc\/inetd.conf<\/file> file. If <command>inetd<\/command> is told to wait (there is a wait in the\nflags\/fourth column), then the\nserver that was called must process the incoming message before inetd can go on. If told not to wait\n(there is a nowait in the fourth column), inetd will continue to process incoming requests on that\nport. If you look in <file type=\"\">\/etc\/inetd.conf<\/file> you see that almost exclusively <glossary>TCP<\/glossary>\nports are no wait and UDP ports are wait.\n<\/p>\n<p>\nNote that the <command>inetd<\/command> will start the program listed in <file type=\"\">\/etc\/inetd.conf<\/file> based on\nthe port requested (which is listed in <file type=\"\">\/etc\/services<\/file>). However, if the\nappropriate program is already running, there is no need for inetd to start it. Therefore, you may\nhave an entry in <file type=\"\">\/etc\/services<\/file>, but not in <file type=\"\">\/etc\/inetd.conf<\/file>. Services that are not started by\n<command>inetd<\/command> are usually referred to as &#8220;stand-alone&#8221; services. You may have case\n(like HTTP or FTP) where the program (i.e. the service) is already running, there is <b>no<\/b> entry\nin <file type=\"\">\/etc\/services<\/file>. This is because such services us well-known ports and typically nothing else is\ngoing to try to use them. However, if you have a &#8220;non-standard&#8221; program using a special port, then\nit needs to write an entry in \/etc\/services to ensure that other programs do not inadvertently use\nthat port.\n<\/p>\n<concept id=\"28\" description=\"A 'connection refused' when trying to access a remote machine may indicate that the service is not configured in \/etc\/inetd.conf.\" \/>\n<concept id=\"29\" description=\"A 'connection refused' when trying to access a remote machine may indicate that the wrong program is started from \/etc\/inetd.conf.\" \/>\n<p>\nLike with the telephone analogy, you might have a busy single or the system does not answer. A busy signal would indicate that a remote machine is already using the particular service. This general does not happen because most services can handle multiple connections. It might also be that there is no answer, in which case you would get a &#8216;connection refused&#8217; refsued message from <command>inetd<\/command>. This happens when the the particular services is not configured in \/etc\/inetd.confc or perhaps not configured correctly. When that happens, inetd does not know what to do an simply refuses the connection.\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Network Services In the discussion above, I used the telnet command as an example of one of the programs that use TCP\/IP. However, there are many others which provide additional services such as transferring files, electronic mail, networking printing, and &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=301\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-301","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=301"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/301\/revisions"}],"predecessor-version":[{"id":639,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/301\/revisions\/639"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}