

When a host IP packet sent to the destination is forwarded through multiple routers, does the destination IP change?
When a host IP packet sent to the destination is forwarded through multiple routers, the destination IP address remains unchanged.
When the ip packet is forwarded via routing, do the source ip and destination ip change?
This question is often asked in recent interviews with network professionals. The answer cannot be changed unless a nat conversion is performed. (Recommended learning: web front-end video tutorial)
But the mac address changes, because the sending end does not know the mac address of the destination host at first, so the mac address changes every time it passes through a router .
How to get the destination mac address?
TCP/IP uses the ARP protocol. For example, if a new intranet is created, if machine A is looking for machine B, when encapsulating FRAME (the data format used by the second layer of OSI), the other party's MAC must be encapsulated. At the beginning, A does not know B's MAC, but only knows the IP. It sends an ARP packet, the source IP is its own, the destination IP is B's, the source MAC is its own, and the destination MAC is broadcast.
Then the request packet is broadcast within the intranet. When other machines receive the packet, they compare the destination IP with their own IP. If not, they discard it. When B received it, he found that the IP was the same as his own, so he agreed to the request of the packet and sent his MAC to A. If B is a machine in another subnet, then the router will determine that B is in another subnet, and then the router will return its MAC to A. When A sends a packet to B in the future, the destination MAC will be encapsulated by the router.
Routing and forwarding process:
When the data flow sent from host A to host B is encapsulated into an IP data packet at the network layer, the header of the IP data packet contains the source address and destination address. Host A will use the 24-bit IP network mask 255.255.255.0 configured on this machine to perform an AND operation with the target address to determine whether the target network address and the network address of this machine are in the same network segment. If not forward the IP packet to the gateway.
Host A will also obtain the MAC address of the default gateway through an ARP request before sending it to the gateway. The IP data packet at the data link layer of host A is encapsulated into an Ethernet data frame and then sent to the gateway... which is a port on the router.
When the gateway router receives the Ethernet data frame and finds that the target MAC address in the data frame is the physical address of one of its own ports, the router will remove the encapsulation of the Ethernet data frame. The router thinks that this IP packet is to be forwarded through itself, and then it matches the routing table. After matching the routing entry, it sends the packet to the next address.
This is how the router forwards data packets, so it will never change the IP address. Only the MAC will be changed.
When a data packet is transmitted to the router, the router first compares its destination address with the routing table. If it is a local network, it will not be forwarded to the external network. Instead, it is forwarded directly to the destination host in the local network; but if the destination address is compared with the routing table and it is found that it is not in the local network, if there is NAT, the IP of the source address will be changed (the IP address of the original source address will be changed to the IP address of the router) ), the router forwards the data packet to the corresponding port for communication.
The above is the detailed content of When a host IP packet sent to the destination is forwarded through multiple routers, does the destination IP change?. 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

AI Hentai Generator
Generate AI Hentai for free.

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).

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.

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

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 methods for querying the IP address of this machine are: 1. Under Windows system, open the "Start Menu" and search for "cmd" to open the command prompt, enter "ipconfig", and then press the Enter key to find a line named "IPv4 Address" , the number next to it is the IP address of the machine; 2. Under macOS system, click the Apple icon in the upper left corner of the screen, select "System Preferences", find the currently connected network in the "Network" option, and click the "Advanced" button , find the IP of the machine in the "TCP/IP" tab, etc.

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.

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