Explain in detail the computer's IP address, subnet mask, default gateway and DNS servers

 

To Windows system settings interface IP address as a reference (Figure 1), IP address, subnet mask, default gateway and DNS server, these are what does that mean?

 

An IP address

Outline

To implement the computer network communication, it must have a network address for quick orientation. IP address is the unique ID in a computer network, with real-world courier delivery requires a specific home address is a reason.

ip address numbers separated by dots showing four decimal numbers, each number from 0 to 255, such as a host ip address is: 128.20.4.1

The composition of IP addresses

Address = address + IP network host address (also known as: network number and host number Composition)

Think about why there is a delineation of administrative divisions (national, provincial and urban areas, streets, etc.), in order to more efficiently manage localization;

The same, we usually network can also be divided into many sub-networks, each sub-network has its own network address, each sub-network consists of many computer components (of course, can also contain another subnet).

We want to find the specified IP address, as long as the first find the specified network address, and then within the network to find the corresponding host address.

IP address is a 4 * 8bit (1 byte) numeric string consisting of a 0/1 (IP4 protocol)

Win7 article opened with the IP address of the screenshot of 192.168.1.168, subnet mask 255.255.255.0 (Detailed below there), for example, the address contains a lot of meaning:

192.168.100.168 (IP address) = 192.168.1.0 (network address) + 0.0.0.168 (host address)

Network address, host address is how it calculated? We simply need to learn under the subnet mask

Two subnet mask (subnet mask)

IP network address and host address is the number of bits represent it? If you do not, you do not know which bits are the network number, which is the host number, which need to be implemented by the subnet mask.

Outline

Called network mask subnet mask, the mask address, subnet mask, is a 4 * 8bit (1 byte) numeric string consisting of 0/1.

Its role is to shield (cover) part of the IP address to the network is divided into two parts and host addresses, and indicates that the IP address is on the LAN, or on a remote network.

By the subnet mask, the network can be divided into subnets, i.e. VLSM (variable length subnet mask), a small network can also merge into a large network is the super net.

Subnet mask can not exist alone, it must be combined with the IP address.

Subnet mask rules

A length of 4 * 8bit (1 byte), a continuous and consecutive 0 1 composed of two parts,

For example: 11111111.11111111.11111111.00000000 corresponding decimal: 255.255.255.0

Suppose, IP addresses of the computers on the LAN A is 192.168.1.1, the subnet mask 255.255.255.0, and shown below:

 
 

Network Address: the cover portion is 1 IP address continuously, i.e. 11000000.10101000.00000001.00000000, corresponding network addresses: 192.168.1.0

Host address: IP address of the covered portions of consecutive 0, i.e. 00000000.00000000.00000000.00000001, corresponding network address: 0.0.0.1

The network exclude two special addresses:

Broadcast address: 192.168.1.255 (whole host No. 11111111) (see link broadcast mechanism and type

Network address: 192.168.1.0 (host number are all 00000000)

The maximum number of hosts in the subnet: 8 th of 2562 - 2

other information:

Class A addresses, the subnet mask 255.0.0.0 default; Class B subnet mask default address is 255.255.0.0; default for a class C address for subnet mask 255.255.255.0 .

By calculating the subnet mask address three networks

Reference: "IP address, subnet mask, default gateway, DNS server explanation"

Calculation

The calculation process is as follows:

1. The IP address and subnet mask are converted into binary;

2. Both for the "operation and" obtain the network address.

Calculation: vertical alignment, an operator 1, 1 and 1 = 1, the remaining composition is 0

Operational 1011

-------------------

Results 1010

Assume that the IP address 192.168.1.168, subnet mask 255.255.255.0, and then the network address translation steps:

1) The IP address and subnet mask are converted into binary

192.168.1.168 is converted into a binary 11000000.10101000.00000001.10101000

255.255.255.0 is converted into a binary 11111111.11111111.11111111.00000000

2) The both ANDed

3) The calculation result is converted into decimal: 192.168.1.0

Practice immediately

To link the two computers directly with a network cable as an example:

 

image 3

Here are some IP address, or to see through the network is nowhere in different settings.

 

Description: The first case is because it can pass both computers at the same 192.168.0.0 network, we are able to pass, and the lower case 3 of the two computers in different networks, it is nowhere.

Calculation of network address as above mentioned.

in conclusion:

Directly or via a T4 HUB (hub), the switch common link must be in the same network computer (network address) of a network cable and the host address is not the same need to communicate.

Note: The network does not refer to the same physical connection, but refers to the network address.

For example, two computers linked to the same router (simply understood as the same link), the network address if they are inconsistent setting, they are unable to communicate.

Extended: IP network notation

Illustration: 192.168.0.0/24

192.168.0.0: Network Address

24: subnet mask binary notation, the number of consecutive 1, here: 11111111 * 11111111 * 11111111 * 00000000, i.e., 255.255.255.0

IV. The default gateway (address)

Reference: "Baidu Encyclopedia - Gateway"

What is a gateway?

(Can be associated with lower customs? What are the customs?)

Two different devices connected to the network can be called a gateway device; the role of the gateway is to achieve communication and control between two networks.

Gateway device may be interactive machine (three or more to cross-network), routers, routing protocol enabled server, proxy server, firewall, etc.

Gateway IP address is the address of the gateway device.

Suppose we have two networks:

网络A的IP地址范围为“192.168.1.1~192.168.1.254”,子网掩码为255.255.255.0

网络B的IP地址范围为“192.168.2.1~192.168.2.254”,子网掩码为255.255.255.0

要实现这两个网络之间的通信,则必须通过网关。

 

只有设置好网关的IP地址,TCP/IP协议才能实现不同网络之间的相互通信。

默认网关

一台主机可以有多个网关。默认网关的意思是一台主机如果找不到可用的网关,就把数据包发给默认指定的网关,由这个网关来处理数据包。现在主机使用的网关,一般指的是默认网关。

扩展:自动设置默认网关

自动设置就是利用DHCP(Dynamic Host Configuration Protocol, 动态主机配置协议)服务器来自动给网络中的计算机分配IP地址、子网掩码和默认网关 。

一旦网络的默认网关发生了变化时,只要更改了DHCP服务器中默认网关的设置,那么网络中所有的计算机均获得了新的默认网关的IP地址。这种方法适用于网络规模较大、TCP/IP参数有可能变动的网络。

另外一种自动获得网关的办法是通过安装代理服务器软件(如MS Proxy)的客户端程序来自动获得,其原理和方法和DHCP有相似之处。

扩展说明

问:在网上看到一些人提问:连接到相同(二层)交换机或集线器上的计算机,如果设置不同的网络地址,为什么不能通信。

答:

在 TCP/IP 协议中,网络层(通过IP地址识别通信方)封包完成交给下一层数据链路层(通过MAC地址识别通信方)时,需要通过 ARP 广播 获取目标 IP 对应的 MAC 地址。

但因为 ARP 报文只能在相同网络地址内广播,如果目标计算机与源计算机处于不同网络,则无法进行响应,因此源计算机无法完成链路层数据的封装。

ARP 协议相关信息可见 这里。

五. DNS服务器

域名与DNS

我们访问一个网站的时候,往往使用的是域名(相对IP来说更加语义清晰、更加容易记忆,例如 www.baidu.com)。

域名是由一串用点分隔的名字组成的,通常包含组织名,而且始终包括两到三个字母的后缀,以指明组织的类型或该域所在的国家或地区。

然而计算机之间的通信网络通信是通过IP进行的, 因此需要将域名解析为对应的IP,DNS就是进行域名解析的服务器。

DNS 维护着 域名(domain name)和IP地址 (IP address)的对照表表,以解析消息的域名。

DNS 查询的过程如下图所示

 

1、在浏览器中输入www.qq.com域名,操作系统会先检查自己本地的hosts文件是否有这个网址映射关系,如果有,就先调用这个IP地址映射,完成域名解析。

2、如果hosts里没有这个域名的映射,则查找本地DNS解析器缓存,是否有这个网址映射关系,如果有,直接返回,完成域名解析。

3、如果hosts与本地DNS解析器缓存都没有相应的网址映射关系,首先会找TCP/ip参数中设置的首选DNS服务器,在此我们叫它本地DNS服务器,此服务器收到查询时,如果要查询的域名,包含在本地配置区域资源中,则返回解析结果给客户机,完成域名解析,此解析具有权威性。

4、如果要查询的域名,不由本地DNS服务器区域解析,但该服务器已缓存了此网址映射关系,则调用这个IP地址映射,完成域名解析,此解析不具有权威性。

5、如果本地DNS服务器本地区域文件与缓存解析都失效,则根据本地DNS服务器的设置(是否设置转发器)进行查询,如果未用转发模式,本地DNS就把请求发至13台根DNS,根DNS服务器收到请求后会判断这个域名(.com)是谁来授权管理,并会返回一个负责该顶级域名服务器的一个IP。本地DNS服务器收到IP信息后,将会联系负责.com域的这台服务器。这台负责.com域的服务器收到请求后,如果自己无法解析,它就会找一个管理.com域的下一级DNS服务器地址(qq.com)给本地DNS服务器。当本地DNS服务器收到这个地址后,就会找qq.com域服务器,重复上面的动作,进行查询,直至找到www.qq.com主机。

6、如果用的是转发模式,此DNS服务器就会把请求转发至上一级DNS服务器,由上一级服务器进行解析,上一级服务器如果不能解析,或找根DNS或把转请求转至上上级,以此循环。不管是本地DNS服务器用是是转发,还是根提示,最后都是把结果返回给本地DNS服务器,由此DNS服务器再返回给客户机。

Guess you like

Origin www.cnblogs.com/memry/p/11445512.html