I've read a book on the theory of computer networks, and now I'm familiar with some protocols such as TCP, IP, Ethernet, etc. However, in practice, in any modern operating system, you also have some other abstraction called "network interface". But in the RFC standards and theory books there's not a single word about this essential concept.
I have such questions:
1. What is a network interface?
2. I've heard that network interfaces were invented to "simplify networks administration". How exactly do they simplify this?
3. How do network interfaces correspond to network protocols (Ethernet, IP, TCP) and their OSI layers? Am I right that interface represents a "host" in an IP network? But why then can there be an interface without an IP address?
4. How do network interfaces correspond to linux sockets? Is a certain interface implicitly selected when you send some data over a socket?
5. Why is there a separate interface for the loopback address 127.0.0.1?
6. What is a typical reason for defining a new network interface on a server?
I haven't found any detailed description of network interfaces other than practical guides on how to use some real tools to "up" them or "down", assign an ip address, and the like.
CodePudding user response:
A network interface is a physical or logical device that enables a computer or other device to connect to a network and exchange data with other devices on the network. This can include a wide variety of devices, such as Ethernet cards, wireless adapters, and virtual network interfaces.
Network interfaces simplify network administration by providing a standard way for devices to connect to a network and communicate with each other. This allows network administrators to easily configure and manage network connections without having to worry about the specific details of each device's hardware or software.
Network interfaces correspond to network protocols and their OSI layers in that they provide the physical connection and data transmission capabilities that allow the protocols to operate. For example, an Ethernet interface would correspond to the OSI model's Physical and Data Link layers, while an IP interface would correspond to the Network layer. An interface can represent a "host" in an IP network, but it is not required to have an IP address in order to function.
Network interfaces and Linux sockets are related in that they both provide a way for a computer to connect to a network and exchange data. However, a network interface is a physical or logical device that provides the actual connection to the network, while a socket is a software abstraction that allows applications to access the network through the interface. When sending data over a socket, a specific interface is not necessarily selected, as the socket API provides a way for the application to specify the destination address and let the operating system choose the appropriate interface.
The loopback interface is a special interface that is used to communicate with the local host rather than with other devices on the network. This allows a device to send and receive data to itself, which can be useful for testing and development purposes. The loopback address (127.0.0.1) is typically associated with this interface and is used to identify the local host when sending data over the loopback interface.
A typical reason for defining a new network interface on a server would be to add additional network connectivity or to improve network performance. For example, a server might have multiple network interfaces to allow it to connect to multiple networks or to provide failover capabilities in case one of the interfaces goes down. Additionally, a server might use multiple interfaces to increase its overall network bandwidth or to separate different types of traffic onto different interfaces to improve performance.
Also check Official Internet Protocol Standards and Introduction to Network Interfaces