Это старая версия документа.
TCP/IP
Протокол управления передачей и межсетевой протокол (TCP/IP) - это стандартный набор протоколов, разработанный в конце 1970-х Агентством передовых оборонных исследовательских проектов (DARPA) как средство взаимодействия между различными типами компьютеров и компьютерными сетями. TCP/IP является движущей силой интернета и поэтому является самым популярным стеком сетевых протоколов на Земле.
Введение в TCP/IP
Два компонента протокола TCP/IP представляют разные аспекты компьютерного взаимодействия. Межсетевой протокол («IP» в TCP/IP) - это протокол без установления соединения, который предоставляет только маршрутизацию пакетов, используя IP пакет (datagram) как основной блок сетевой информации. IP пакет содержит заголовок с последующим сообщением. Протокол управления передачей («TCP» в TCP/IP) позволяет сетевым хостам устанавливать соединения, которые могут использоваться для передачи потоков данных. TCP также гарантирует, что данные между подключениями будут доставлены и что они придут на сетевой хост в том же порядке, как они были посланы с другого.
Настройка TCP/IP
Настройка протокола TCP/IP состоит из нескольких элементов, которые должны быть установлены через редактирование конфигурационных файлов, или использования таких решений как сервер DHCP, который будучи включен может быть настроен на раздачу правильных TCP/IP настроек клиентам сети автоматически. Эти параметры настроек должны быть установлены корректно для облегчения правильного сетевого взаимодействия вашей системы Ubuntu.
Общие элементы настройки TCP/IP и их назначение следующие:
IP адрес IP адрес - это уникальная идентифицирующая строка, представленная в виде четырех десятичных чисел от 0 до 255, разделенных точками, каждое из которых представляет 8-битный адрес, составляющие полный 32-битный адрес Этот формат называют точечной четверичной записью (dotted quad notation).
Сетевая маска Маска подсети (или просто сетевая маска) - это локальная побитовая маска или набор флагов, которые разделяют IP адрес на часть, значимую для всей сети, и биты, значимые для данной подсети. Например, в сети класса C стандартная сетевая маска 255.255.255.0, которая маскирует первые 3 байта IP адреса и делает последний байт адреса доступным для хостов, определенных в подсети.
Адрес сети Адрес сети представляет собой байты, составляющие сетевую часть IP адреса. Например, хост 12.128.1.2 в сети класса A будет использовать 12.0.0.0 в качестве адреса сети, где 12 представляет первый байт IP адреса (сетевая часть) и нули в оставшихся трех байтах для предоставления возможных значений для хостов. Сетевой хост, использующий частный IP адрес 192.168.1.100 будет использовать для адреса сети 192.168.1.0, который определяет первые три байта сети 192.168.1 класса C и 0 для всех возможных хостов сети.
Адрес рассылки
Broadcast Address The Broadcast Address is an IP address which allows network data to be sent simultaneously to all hosts on a given subnetwork rather than specifying a particular host. The standard general broadcast address for IP networks is 255.255.255.255, but this broadcast address cannot be used to send a broadcast message to every host on the Internet because routers block it. A more appropriate broadcast address is set to match a specific subnetwork. For example, on the private Class C IP network, 192.168.1.0, the broadcast address is 192.168.1.255. Broadcast messages are typically produced by network protocols such as the Address Resolution Protocol (ARP) and the Routing Information Protocol (RIP).
Gateway Address A Gateway Address is the IP address through which a particular network, or host on a network, may be reached. If one network host wishes to communicate with another network host, and that host is not located on the same network, then a gateway must be used. In many cases, the Gateway Address will be that of a router on the same network, which will in turn pass traffic on to other networks or hosts, such as Internet hosts. The value of the Gateway Address setting must be correct, or your system will not be able to reach any hosts beyond those on the same network.
Nameserver Address Nameserver Addresses represent the IP addresses of Domain Name Service (DNS) systems, which resolve network hostnames into IP addresses. There are three levels of Nameserver Addresses, which may be specified in order of precedence: The Primary Nameserver, the Secondary Nameserver, and the Tertiary Nameserver. In order for your system to be able to resolve network hostnames into their corresponding IP addresses, you must specify valid Nameserver Addresses which you are authorized to use in your system's TCP/IP configuration. In many cases these addresses can and will be provided by your network service provider, but many free and publicly accessible nameservers are available for use, such as the Level3 (Verizon) servers with IP addresses from 4.2.2.1 to 4.2.2.6.
The IP address, Netmask, Network Address, Broadcast Address, and Gateway Address are typically specified via the appropriate directives in the file /etc/network/interfaces. The Nameserver Addresses are typically specified via nameserver directives in the file /etc/resolv.conf. For more information, view the system manual page for interfaces or resolv.conf respectively, with the following commands typed at a terminal prompt:
Access the system manual page for interfaces with the following command:
man interfaces
Access the system manual page for resolv.conf with the following command:
man resolv.conf
IP Routing
IP routing is a means of specifying and discovering paths in a TCP/IP network along which network data may be sent. Routing uses a set of routing tables to direct the forwarding of network data packets from their source to the destination, often via many intermediary network nodes known as routers. There are two primary forms of IP routing: Static Routing and Dynamic Routing.
Static routing involves manually adding IP routes to the system's routing table, and this is usually done by manipulating the routing table with the route command. Static routing enjoys many advantages over dynamic routing, such as simplicity of implementation on smaller networks, predictability (the routing table is always computed in advance, and thus the route is precisely the same each time it is used), and low overhead on other routers and network links due to the lack of a dynamic routing protocol. However, static routing does present some disadvantages as well. For example, static routing is limited to small networks and does not scale well. Static routing also fails completely to adapt to network outages and failures along the route due to the fixed nature of the route.
Dynamic routing depends on large networks with multiple possible IP routes from a source to a destination and makes use of special routing protocols, such as the Router Information Protocol (RIP), which handle the automatic adjustments in routing tables that make dynamic routing possible. Dynamic routing has several advantages over static routing, such as superior scalability and the ability to adapt to failures and outages along network routes. Additionally, there is less manual configuration of the routing tables, since routers learn from one another about their existence and available routes. This trait also eliminates the possibility of introducing mistakes in the routing tables via human error. Dynamic routing is not perfect, however, and presents disadvantages such as heightened complexity and additional network overhead from router communications, which does not immediately benefit the end users, but still consumes network bandwidth.
TCP and UDP
TCP is a connection-based protocol, offering error correction and guaranteed delivery of data via what is known as flow control. Flow control determines when the flow of a data stream needs to be stopped, and previously sent data packets should to be re-sent due to problems such as collisions, for example, thus ensuring complete and accurate delivery of the data. TCP is typically used in the exchange of important information such as database transactions.
The User Datagram Protocol (UDP), on the other hand, is a connectionless protocol which seldom deals with the transmission of important data because it lacks flow control or any other method to ensure reliable delivery of the data. UDP is commonly used in such applications as audio and video streaming, where it is considerably faster than TCP due to the lack of error correction and flow control, and where the loss of a few packets is not generally catastrophic.
ICMP
The Internet Control Messaging Protocol (ICMP) is an extension to the Internet Protocol (IP) as defined in the Request For Comments (RFC) #792 and supports network packets containing control, error, and informational messages. ICMP is used by such network applications as the ping utility, which can determine the availability of a network host or device. Examples of some error messages returned by ICMP which are useful to both network hosts and devices such as routers, include Destination Unreachable and Time Exceeded.
Daemons
Daemons are special system applications which typically execute continuously in the background and await requests for the functions they provide from other applications. Many daemons are network-centric; that is, a large number of daemons executing in the background on an Ubuntu system may provide network-related functionality. Some examples of such network daemons include the Hyper Text Transport Protocol Daemon (httpd), which provides web server functionality; the Secure SHell Daemon (sshd), which provides secure remote login shell and file transfer capabilities; and the Internet Message Access Protocol Daemon (imapd), which provides E-Mail services.