当前位置:网站首页>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 .
边栏推荐
- 【ASM】字节码操作 ClassWriter 类介绍与使用
- Wechat applet obtains mobile number
- Pyspark operator processing spatial data full parsing (5): how to use spatial operation interface in pyspark
- VR panoramic wedding helps couples record romantic and beautiful scenes
- 10 advanced concepts that must be understood in learning SQL
- Is it meaningful for 8-bit MCU to run RTOS?
- Smart street lamp based on stm32+ Huawei cloud IOT design
- 基本磁盘与动态磁盘 RAID磁盘冗余阵列区分
- Sqoop I have everything you want
- Today in history: the mother of Google was born; Two Turing Award pioneers born on the same day
猜你喜欢
[ASM] introduction and use of bytecode operation classwriter class
传统家装有落差,VR全景家装让你体验新房落成效果
在一台服务器上部署多个EasyCVR出现报错“Press any to exit”,如何解决?
Is it meaningful for 8-bit MCU to run RTOS?
BearPi-HM_ Nano development environment
How to use scroll bars to dynamically adjust parameters in opencv
Wordcloud colormap color set and custom colors
FMT开源自驾仪 | FMT中间件:一种高实时的分布式日志模块Mlog
BearPi-HM_ Nano development board "flower protector" case
基本磁盘与动态磁盘 RAID磁盘冗余阵列区分
随机推荐
Pytorch extract middle layer features?
What is the reason why the video cannot be played normally after the easycvr access device turns on the audio?
Hongmeng introduction and development environment construction
node の SQLite
8位MCU跑RTOS有没有意义?
How to solve the error "press any to exit" when deploying multiple easycvr on one server?
EasyCVR电子地图中设备播放器loading样式的居中对齐优化
偷窃他人漏洞报告变卖成副业,漏洞赏金平台出“内鬼”
MarkDown语法——更好地写博客
【Elastic】Elastic缺少xpack无法创建模板 unknown setting index.lifecycle.name index.lifecycle.rollover_alias
分布式不来点网关都说不过去
Unity粒子特效系列-闪星星的宝箱
C语言指针*p++、*(p++)、*++p、*(++p)、(*p)++、++(*p)对比实例
Unity小技巧 - 绘制瞄准准心
Debug and run the first xv6 program
Xin'an Second Edition; Chapter 11 learning notes on the principle and application of network physical isolation technology
Xin'an Second Edition: Chapter 25 mobile application security requirements analysis and security protection engineering learning notes
BearPi-HM_ Nano development board "flower protector" case
VR全景婚礼,帮助新人记录浪漫且美好的场景
EasyCVR授权到期页面无法登录,该如何解决?