当前位置:网站首页>IP, subnet mask, gateway, default gateway
IP, subnet mask, gateway, default gateway
2022-07-06 17:53:00 【TABE_】
Here's the catalog title
ip
ip Address = network address + The host address ( also called : Network number and host number ), We call the host with the same network number as the host in the local network , Hosts with different network numbers are called hosts in the remote network . Hosts in the local network can communicate with each other directly , In order to communicate with each other, the hosts in the remote network must pass through the local gateway (Gateway) To deliver forwarding data .
ip The main addresses are A、B、C、D、E Five types of address :
- A class : from 1 Byte network address and 3 Byte host address composition , The highest bit of the network address must be “0”( All network addresses are 0 The address of is reserved for use ). The address range is 1.0.0.0 To 127.255.255.255, It is mainly allocated to large-scale networks with a large number of hosts and a small number of LAN networks ;
- B class : from 2 Byte network address and 2 Byte host address composition , The top two digits of the network address must be “10”. The address range is 128.0.0.0 To 191.255.255.255, Generally used in large international companies and government agencies ;
- C class : from 3 Byte network address and 1 Byte host address composition , The highest bit of the network address must be “110”. The address range is 192.0.0.0 To 223.255.255.255, For general small company campus network research institutions, etc ;
- D class : The first byte consists of “1110” Start . All zeros (“0.0.0.0”) The address corresponds to the current host . whole “1” Of IP Address (“255.255.255.255”) Is the broadcast address of the current subnet . The address range is 224.0.0.0 To 239.255.255.255, Also known as broadcast address , So any first byte is greater than 223 Less than 240 Of IP The address is the multicast address .
- E class : from “11110” Start , The address range is 240.0.0.0 To 255.255.255.255, For the time being .
network address
Calculating the network address is to determine whether the computers in the network are on the same network , You can get through , You can't get through without , Need the help of local gateway .
take IP The address and subnet mask are all converted to binary form , Then the result of the phase by phase sum of the two is the network address .
IP Decimal system :192.168.1.1
IP Binary system :11000000 10101000 00000001 00000001
Subnet mask decimal :255.255.255.0
Subnet mask binary :11111111 11111111 11111111 00000000
network address = IP & Subnet mask
Network address binary :11000000 10101000 00000001 00000000
Network address decimal :192.168.1.0
The host address
IP The result of not matching the subnet mask is the host address .
IP Decimal system :192.168.1.1
IP Binary system :11000000 10101000 00000001 00000001
Subnet mask decimal :255.255.255.0
Subnet mask binary :11111111 11111111 11111111 00000000
The host address = IP & (~ Subnet mask )
Host address binary :00000000 00000000 00000000 00000001
Host address decimal :0.0.0.1
Subnet mask
The representation of subnet mask
(1) Dotted decimal notation
Binary to decimal , Every time 8 The places are separated by dots .
for example : Subnet mask binary 11111111.11111111.11111111.00000000, Expressed as 255.255.255.0
(2)CIDR slash notation
IP Address /n
example 1:192.168.1.100/24, Its subnet mask is expressed as 255.255.255.0, Binary representation as 11111111.11111111.11111111.00000000
example 2:172.16.198.12/20, Its subnet mask is expressed as 255.255.240.0, Binary representation as 11111111.11111111.11110000.00000000
It's not hard to find out , example 1 The Communist Party of China has 24 individual 1, example 2 The Communist Party of China has 20 individual 1, therefore n It's like this . Operator, ISP This method is often used to assign... To customers IP Address .
notes :n by 1 To 32 The number of , Indicates the length of the network number in the subnet mask , adopt n Determine the number of hosts in the subnet =2^(32-n)-2(-2 Why : All hosts are 0 Indicates the network address of the network , All hosts are 1 Indicates the broadcast address of the network , These are two special addresses ).
Why use a subnet mask ?
Said before , The subnet mask can be separated IP Network address and host address in the address , Then why separate ? Because the two hosts need to communicate , First of all, it is necessary to judge whether they are in the same network segment , Whether the network address is the same . If the same , Then you can send the packet directly to the target host , Otherwise, the routing gateway is required to forward the data packet to the destination .
It's easy to understand :A The host should be connected with B Host communication ,A and B Respective IP Address and A The subnet mask of the host And And operation , The visible result :
- If the results are the same , It means that the two hosts are in the same network segment , such A Can pass ARP Broadcast discovery B Of MAC Address ,B It can also be found A Of MAC Address to achieve normal communication .
- If the results are different ,ARP The broadcast will end at the local gateway , Now A Will send to B The packet is sent to the local gateway first , The gateway is then based on B The host IP Address to query the routing table , Then continue to deliver and forward the packet , Finally sent to the destination B.
Classification of subnet masks
(1) The default subnet mask
Also known as the default subnet mask , That is, there is no subnet , The corresponding network number is set to 1 , All the host numbers are set 0 .
Not divided into subnets IP Address : network number + Host number , be :
- A Class network default subnet mask : 255.0.0.0, use CIDR Expressed as /8
- B Class network default subnet mask : 255.255.0.0, use CIDR Expressed as /16
- C Class network default subnet mask : 255.255.255.0, use CIDR Expressed as /24
(2) Custom subnet mask
After dividing a network into subnets , Give a part of the original host number location to the subnet number , The rest is the host number of the subnet . Its form is as follows :
After the subnet division IP Address : network number + Subnet number + Subnet host number , for instance :
- 192.168.1.100/25, Its subnet mask indicates :255.255.255.128, It means that you will 192.168.1.0 The highest host bit of this network segment 1 The bits are divided into subnets .
gateway
Computer gateway (Gateway) Is the exit to other network segments , That is, the router interface IP Address . The router interface uses IP The address can be any address in this network segment , However, the first available address or the last available address of the network segment is usually used , This is to avoid conflicts with the host addresses in this network segment as much as possible .
In the following topology illustration example ,A And B,C And D, Can communicate directly with each other ( All belong to the same network segment , You don't have to go through the router ), however A And C,A And D,B And C,B And D They do not belong to the same network segment , So they communicate through the local gateway , Then the router according to each other IP Address , Find the exact match in the routing table IP Direct routing of addresses , So it is forwarded from the gateway interface on the other side to realize interconnection .

The default gateway
The default gateway address is set to all except the last host bit 1 Later obtained .
Let's say there's a ip The address is 193.6.7.0/24, According to the network prefix 24 Before we know 24 Bit is network bit , after 8 Bit is host bit , Therefore, the default gateway address of the network is IP Address 193.6.7.11111110( The bold part is the host bit ), Convert to decimal number, that is 193.6.7.254/24.
A host can have multiple gateways . The default gateway means that if a host cannot find an available gateway , Send the packet to the default gateway , This gateway handles packets . Now the gateway used by the host , It generally refers to the default gateway . The default gateway of a computer can't be specified casually , Must specify... Correctly , Otherwise, a computer will send packets to a host that is not a gateway , Therefore, it is impossible to communicate with the host of other networks . The default gateway can be set manually or automatically .
(1) Manual settings
The manual setting is suitable for a small number of computers 、TCP/IP When the parameters are basically the same , For example, there are only a few to a dozen computers . Because this method needs to be set up on every computer connected to the network “ The default gateway ”, It's very hard , Once the default gateway has to be modified due to migration and other reasons IP Address , Will bring a lot of trouble to the network management , So... Is not recommended .
stay Windows 9x in , Set the default gateway in “ Online neighbors ” Right click on , Click... In the pop-up menu “ attribute ”, In the network properties dialog box, select “TCP/IP agreement ”, Click on “ attribute ”, stay “ The default gateway ” Tab, fill in the name of the new default gateway IP The address will do .
Here's the thing to watch out for : The default gateway must be in the network segment of the computer itself IP Address , You can't fill in IP Address .
(2) Automatic setting
Automatic setting is to use DHCP(Dynamic Host Configuration Protocol, Dynamic Host Configuration Protocol ) Server to automatically assign computers in the network IP Address 、 Subnet mask and default gateway . The advantage of this is that once the default gateway of the network changes , Just change DHCP The default gateway settings in the server , Then all the computers in the network get the new default gateway IP Address . This method is suitable for large scale networks 、TCP/IP Parameters may change in the network . Another way to get the gateway automatically is by installing the proxy server software ( Such as MS Proxy) The client program to automatically get , Its principle and method and DHCP There are similarities . Limited space , Let's not go into details .
边栏推荐
- Fleet tutorial 13 basic introduction to listview's most commonly used scroll controls (tutorial includes source code)
- Xin'an Second Edition: Chapter 26 big data security demand analysis and security protection engineering learning notes
- Flet教程之 13 ListView最常用的滚动控件 基础入门(教程含源码)
- Guidelines for preparing for the 2022 soft exam information security engineer exam
- PyTorch 提取中间层特征?
- OpenEuler 会长久吗
- RepPoints:可形变卷积的进阶
- Pytorch extract middle layer features?
- 二分(整数二分、实数二分)
- Pourquoi Li shufu a - t - il construit son téléphone portable?
猜你喜欢

node の SQLite

It doesn't make sense without a distributed gateway
![[elastic] elastic lacks xpack and cannot create template unknown setting index lifecycle. name index. lifecycle. rollover_ alias](/img/03/ece7f7b28cd9caea4240635548c77f.jpg)
[elastic] elastic lacks xpack and cannot create template unknown setting index lifecycle. name index. lifecycle. rollover_ alias

EasyCVR授权到期页面无法登录,该如何解决?

C # nanoframework lighting and key esp32
![[translation] principle analysis of X Window Manager (I)](/img/40/6e15e1acebb47061d6e0e4c8ff82ea.jpg)
[translation] principle analysis of X Window Manager (I)

Grafana 9 is officially released, which is easier to use and more cool!

SAP UI5 框架的 manifest.json

scratch疫情隔离和核酸检测模拟 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月

带你穿越古罗马,元宇宙巴士来啦 #Invisible Cities
随机推荐
Example of batch update statement combining update and inner join in SQL Server
BearPi-HM_ Nano development board "flower protector" case
EasyCVR平台通过接口编辑通道出现报错“ID不能为空”,是什么原因?
C # nanoframework lighting and key esp32
酷雷曼多种AI数字人形象,打造科技感VR虚拟展厅
Essai de pénétration du Code à distance - essai du module b
VR panoramic wedding helps couples record romantic and beautiful scenes
微信小程序获取手机号
Compile and build, from the bottom to the top
Manifest of SAP ui5 framework json
面试突击63:MySQL 中如何去重?
Selected technical experts from China Mobile, ant, SF, and Xingsheng will show you the guarantee of architecture stability
Appium automated test scroll and drag_ and_ Drop slides according to element position
Wordcloud colormap color set and custom colors
Establishment of graphical monitoring grafana
Flet教程之 13 ListView最常用的滚动控件 基础入门(教程含源码)
学 SQL 必须了解的 10 个高级概念
Spark accumulator and broadcast variables and beginners of sparksql
Reppoints: advanced order of deformable convolution
二分(整数二分、实数二分)