Linux Review Memorandum 8

Source: Internet
Author: User

This is the eighth article in this series. Starting from this article, we have basically finished introducing the basic knowledge of the system. The following describes the configurations of networks and related applications. Of course, the previous article is a bit simple, mainly because it takes time to type !!! A lazy person like me can give me an outline to remind myself that it is already a great experience.

First, let's talk about the TCP/IP protocol. This is a factual standard. After the International Organization for Standardization defines the so-called OSI Layer-7 Protocol (which is not actually applied ).

Let's take a look at the layered graph first :,

8.1 basic knowledge

TCP is the transmission control protocol, while IP is the Internet protocol.

TCP and UDP are the transmission protocols used to transmit packets to specific applications based on IP addresses.

TCP is a connection-oriented protocol, which is a bit like a phone. Reliable and controllable transmission over TCP. UDP is a group-oriented service, similar to the Post Office Mail principle. UDP is a non-connection protocol. It does not guarantee the receipt and sending order of the group, nor does it ensure that the Group can arrive at the destination correctly.

8.2 network connection technology Overview

The TCP/IP protocol is a protocol family that includes not only the two transport layer protocols, but also ICMP and APR.

The imcp protocol is the underlying support protocol of the IP protocol, while ARP is the Address Resolution Protocol, which is also common for various tests.

8.2.1 grouping and Encapsulation

In the network, high-level protocols do not care about the underlying layer. They seem to be black boxes. This is a very important concept in computers, called encapsulation.

Data is transmitted in groups over the network. Each package consists of a packet header and a payload. The name of the original data unit depends on the protocol layer. The link layer is called frame, the IP layer is called packet, and the TCP layer is called segment ); when a packet is transmitted down the protocol stack, each Protocol adds its own header. This nested process is called encapsulation, and the opposite inverse process at the receiver is called unblocking.


8.2.2 Link Layer

Here, let's talk about the content of the link layer. The main task of the link layer is to add the frame header to the data frame, and the separator between the frames to distinguish different frames. The frames also have standard files, specifies the frame format and other information.


8.2.3 package addressing

There are basically three solutions for addressing:

MAC for hardware;

Software IP address;

Addressing with host names;

We should be familiar with MAC addresses. This is an address initialized at the factory of the NIC. Of course, you can pretend to be the address in the system. I will not explain it.

Mac addressing is a link layer-based addressing method. The ing between IP addresses and hardware addresses is also implemented at the link layer: ARP. This Protocol is at the link layer.

8.2.4 IP Port

The IP address indicates the network interface of the computer, but for services and processes, an IP address cannot distinguish different processes, so the concept of port is derived. In Linux, the port numbers of service programs are lower than 1024, except for processes running as root.

8.3 IP address details

The IP address is divided into the network part and the host part.

8.3.1 category

Traditionally, IP addresses are divided into three categories: A, B, and C. However, this category has no practical significance. A little bit:

Class A address: the first byte value: 1-126;

Class B address: 128-191;

Class C address: 192-223

8.3.2 subnet and subnet mask

For Network A and Network B, there are too many host numbers. As for the waste of a large number of addresses, the concept of subnet emerged to make better use of IP Address resources.

That is, we can convert a Class B address into multiple Class C addresses in the form of a subnet mask. The mask means to set the network mask position of the brother in the Network part of an IP address to 1, the host space is 0. The common mask is 255.255.255.0, which is the mask of class C addresses.

However, as the number of computers on the network increases, the form of dividing subnets is gradually insufficient. Currently, CIDR classless domain routing is used, in the IP/26 notation, the first 26 bits are the network part, the first two bits in the last byte are the network signs, and the last byte is changed to a mask of 11000000. Therefore, we can divide IP Address/24 into four IP addresses/26 networks. In this example, the remaining six digits of IP Address/26 indicate the host address. If it is normal, it should be 64 hosts, however, the addresses of all 0 and 1 are reserved, so 62 addresses are actually available.

If you are interested, you can continue to study it and do not describe it in detail. In actual application, this is basically useless, but it is a basic knowledge.

8.3.3 CIDR

This is short for classless domain routing classification method. It abolished the previously fixed ABC Classification Method and directly expanded the subnet method. This term is also mentioned in the previous section. You can understand it.

8.3.4 private address and Nat

The configurations of NAT will be discussed later. Here we will only mention their usage.

We know that IP addresses need to be applied, but our internal network expansion is very rapid, and there is no need for each internal host to need an external IP address, so the concept of private IP addresses has emerged, the RFC stipulates that a class a network, 16 class B networks, and 256 Class C networks are used as private addresses.

These addresses can be used internally for your own use. They can be divided into subnets and allocated addresses.

To allow internal hosts to access external networks, a NAT service is generally required to map addresses and ports, that is, all internal IP addresses share a real Internet address. Is this a disadvantage, that is, internal hosts cannot be accessed from outside, but in a specific situation, this seems to be an advantage.

8.4 ARP Address Resolution Protocol

ARP is an important protocol. An IP packet is sent based on the IP address. The actual hardware address must be used on the link layer to transmit data, so ARP is generated. Each computer maintains a table named ARP cache in the memory and stores the results of recent ARP queries.

For this protocol, remember to play a role in the form of broadcast. There is also a command: ARP, which can display the content of the ARP cache.

8.5 Add a host to the network

As a system administrator, you sometimes need to add a host to the network.

The following operations are required:

1. assign IP addresses and host names;

2. Set network interfaces;

3. Set the default route;

4. Specify a DNS server.

8.5.1 assign IP addresses and host names

The files involved may be the/etc/hosts and hostname commands, which are not the focus of this section. This section involves another important command: ifconfig

This command can be said to be very familiar with everyone, and there are similar commands in win system, ipconfig.

The basic format of this command:

Ifconfig interface address options ....

For example:

Ifconfig eth0 192.168.100.1 netmask 255.255.255.0 up

--- Interface is the name of the hardware interface used by the command. Eth0.0.

Address is an IP address, if it is statically allocated.

Netmask is a subnet mask.

Up indicates the startup interface.

The MII-tool command can be used to query and set parameters for a specific interface. Full/half-duplex mode is required. However, unless necessary, it generally does not need to be changed by default.


8.5.2 configure the default route

In fact, it is to specify the gateway address.

Command:

Route add default GW gateway-IP-address

8.5.3 configure DNS

The key to configuring DNS is to configure the/etc/resolv. conf file. You only need to edit this file and add the corresponding DNS server address.

To be continued .....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.