


Detailed explanation of the information displayed by ip addr - IP, MAC
How to check the IP address of this machine? I think this problem will certainly not trouble programmers. Everyone must know that if it is a Windows system, then in the cmd window, enter ipconfig. If you want to see more detailed information, enter ipconfig /all.
If it is a Linux system, if you have installed the net-tools tool, you can use the ifconfig command to view it. But if you have not installed this toolkit, you can also view it through ip addr.
Let’s look at the information displayed by typing ip addr on a host.
# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:16:3e:14:a2:5b brd ff:ff:ff:ff:ff:ff inet 172.16.1.196/20 brd 172.16.15.255 scope global dynamic eth0 valid_lft 291113559sec preferred_lft 291113559sec
This command can display all the network card information on the host. It can be seen that there are currently two network cards on the host, lo and eth0.
IP address
172.16.1.196 is the eth0 network card. IP address, which consists of four parts, each part occupies 8 bits (1 byte), a total of 32 bits. The IP address is the communication address of a network card in the online world, which is equivalent to our house number in the real world. Since it is a house number, everyone is different. If it is the same, an IP address conflict will occur and the Internet will not be able to be accessed.
Classification of IP addresses
Theoretically, there are at most 2 to the 32nd power of IP addresses, which is 4294967296. In fact, there are far more Not nearly so much. IP addresses are divided into 5 categories, and the first three categories A/B/C are actually available.
The following table shows in detail the number of hosts that can be included in the three types of addresses A, B, and C.
Category | ##IP Address Range | Private IP address range | Subnet mask | Number of networks | Maximum number of hosts in a network segment |
A | ##1.0.0.1-127.255.255.254 | ##10.0. 0.0-10.255.255.255##255.0.0.0 | ##126 (2^ 7- 2) | ##16777214 (2^ 24-2) | B |
##128.0.0.1-191.255.255.254 | ##172.16.0.0-172.31 .255.255 | ##255.255.0.0##16383 (2^ 14-1) | 65534 (2^16-2) | ||
##192.168.0.0-192.168.255.255 | 255.255.255.0 | 2097152 (2^ 21-1) | 254 (2^8-2) |
无类型域间选路(CIDR)
看上面表格会发现一个问题,就是C类地址能包含的主机数太少了,只有254个,不够一个大一点的企业使用。而B类又太多了,很少有这么大的单位。所以,就有了一个折中的办法CIDR。
CIDR通过子网掩码将ip地址一分为二,前面的部分为网络号,后面的部分为主机号。下面通过例子看子网掩码是如何划分网络号和主机号的:
172.16.1.196/20
这个地址表示形式就是CIDR。斜杠后面的20即子网掩码,它是由前面连续的20个1组成的,即11111111.11111111.11110000.00000000。表示前20位为网络号,后12位为主机号。所以该网络可用主机数为2的12次方再减去2(一个网络地址、一个广播地址)
将子网掩码和 IP 地址按位AND计算,就可得到网络号。我们来计算下网络号以及第一个可用地址最最后一个可用地址
*.*.00000001.* *.*.11110000.* -------------- 172.16.0.0 <===网络号
获得了网络号,那么第一个可用地址为:172.16.0.1,最后一个可用地址为:172.16.15.254。
伴随着CIDR还有广播地址,172.16.15.255,它是主机号的最后一个。如果发送这个地址,那么172.16.0.0这个网络里的主机都能收到。
公有IP和私有IP
在工作中,基本上不用划分A类、B类还是C类,所以时间长了,大家都忘记了这个分类,只记得CIDR。但是有一点还是要注意的,就是公有 IP 地址和私有 IP 地址。关于私有IP范围,在之前的表格已经给出。当你看到10.x.x.x或172.x.x.x或192.x.x.x时,就要明白,这是个私有ip地址。
那么私有ip和公有ip都是用来干嘛的呢?
公有IP地址是广域网的范畴,通过它能直接访问互联网。如果你想搭建一个网站,让全世界的人都能访问,那么就需要使用公有IP。
私有IP地址:我们企业或家庭内部组建局域网用的IP,一般都会用私有IP。私有地址是局域网范畴内的,私有IP禁止出现在Internet中。
MAC地址
link/ether 00:16:3e:14:a2:5b
这一行显示的是MAC地址,它有12位16进制数组成,用6个字节表示。它是网卡的物理地址,号称全球唯一,不会有两个相同的MAC地址。既然是全球唯一,那么用它来替代ip不是非常好的。
这样是不行的,因为网络中的数据包传递,除了要有确定的地址外,还要有定位功能。MAC地址是不具备远程定位功能的,而IP具有远程定位功能。
MAC地址类似身份证号,每个人身份证号都是唯一的,但是你不能通过这个号去找到这个人的住址。而IP则类似身份证上面的家庭住址信息。
MAC地址虽不具备远程定位功能,但还是有一定的定位功能的(在局域网内)。比如在同一间办公室,你吼一声身份证号xxxxxx是谁,办公室人听到了,有人站起来说是我。但如果这个人在外地(不在同一个网段),你吼破嗓子也没人回应。
总结
IP地址具有定位功能;MAC地址唯一,但不能远程定位
CRID用来划分子网
IP分为公有IP、私有IP。
更多相关技术文章,请访问linux系统教程栏目!
The above is the detailed content of Detailed explanation of the information displayed by ip addr - IP, MAC. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

1. Black/white list IP restricted access configuration nginx There are several ways to configure black and white lists. Here are only two commonly used methods. 1. The first method: allow, denydeny and allow instructions belong to ngx_http_access_module. nginx loads this module by default, so it can be used directly. This method is the simplest and most direct. The setting is similar to the firewall iptable. How to use: Add directly to the configuration file: #Whitelist settings, followed by allow is accessible IPlocation/{allow123.13.123.12;allow23.53.32.1/100;denyall;}#Blacklist settings,

IP and mac binding refers to associating a specific IP address with a specific MAC address, so that only the device using the MAC address can use the IP address for network communication. Binding ip and mac can prevent the IP address of the bound host from being spoofed. Prerequisites: 1. The MAC address is unique and cannot be spoofed; it can only be bound to hosts on the network directly connected to the router (that is, The host's gateway is on the router).

1. Set the directory whitelist: There is no restriction on the specified request path. If there is no restriction on the request path to the api directory, it can be written as server{location/app{proxy_passhttp://192.168.1.111:8095/app ;limit_connconn20;limit_rate500k;limit_reqzone=fooburst=5nodelay;}location/app/api{proxy_passhttp://192.168.1.111:8095/app/api}}#Because nginx will give priority to accurate matching

How to check the IP address on WeChat: 1. Log in to the computer version of WeChat, right-click the taskbar at the bottom of the screen, and click "Task Manager"; 2. When the task manager pops up, click "Details" in the lower left corner; 3. Task management Enter the "Performance" option of the browser and click "Open Resource Monitor"; 4. Select "Network" and check the WeChat process "Wechat.exe"; 5. Click "TCP Connection" below to monitor the WeChat network IP related situation. Sending a message and getting a reply will reveal the other person's IP address.

Concept: uv (uniquevisitor): unique visitor, each independent Internet computer (based on cookies) is regarded as a visitor, and the number of visitors who visit your website within a day (00:00-24:00). Visits to the same cookie within a day are only counted once PV (pageview): visits, that is, page views or clicks, each visit to the website by the user is recorded once. When a user visits the same page multiple times, the total number of visits is counted. Independent IP: The same IP address is only counted once within 00:00-24:00. Friends who do website optimization are most concerned about this. Let me first state the environment. This run nginx version 1.7, the backend tomcat runs dynamic

Solution to wifi showing no IP allocation: 1. Restart the device and router, turn off the Wi-Fi connection on the device, turn off the device, turn off the router, wait a few minutes, then reopen the router to connect to wifi; 2. Check the router settings and restart DHCP, make sure the DHCP function is enabled; 3. Reset network settings, which will delete all saved WiFi networks and passwords. Please make sure they are backed up before performing this operation; 4. Update the router firmware, log in to the router management interface, and find the firmware Update options and follow the prompts.

Introduction When nginx is used as a reverse proxy, the IP address obtained by the default configuration backend comes from nginx. Use request.getRemoteAddr(); to obtain the IP address of nginx, not the user's real IP. 1. Modify Nginx Configuration: server{listen80;server_namejenkins.local.com;location/{proxy_set_headerHost$host;proxy_set_headerX-Real-IP$remote_addr;proxy_passhttp://192.168.10.

The common meanings of IP include "IP address", "intellectual property", "unique selling point" and "independence": 1. IP address is a digital identifier used to identify and locate equipment in computer networks; 2. Intellectual property , refers to the rights and interests enjoyed by people’s intellectual creations, including patents, trademarks, copyrights, trade secrets, etc.; 3. Unique selling points are the unique characteristics of a product or service that distinguish it from competitors and attract customers; 4. Independence refers to the ability of a country or region to make independent decisions and manage itself without external control or interference.
