In network technology, ports have several meanings. The ports of hubs, switches and routers refer to the interfaces connecting other network devices, such as RJ-45 port and serial port. The port we are talking about here is not a physical port, but a port in TCP/IP protocol, which is a logical port.
So what does the port in TCP/IP protocol mean? If the IP address is compared to a house, the port is the door of the house. There are only a few doors in a real house, but an IP address can have as many as 65536 ports (that is, 256×256)! Ports are marked by port numbers, which are only integers between 0 and 65535(256×256).
On the Internet, hosts send and receive data packets through TCP/ip protocol, and each data packet is routed on the Internet according to the ip address of its destination host. It can be seen that there is no problem in successfully transmitting the data packet to the destination host. What's the problem? We know that most operating systems support multiple programs (processes) running at the same time, so which process should the destination host send the received packets to? Obviously, this problem needs to be solved, so the port mechanism is introduced.
The local operating system will assign protocol ports to those processes that need them, and each protocol port is identified by a positive integer, such as 80,139,445, and so on. After receiving the data packet, the destination host will send the data to the corresponding port according to the destination port number of the message header, and the process corresponding to this port will receive the data and wait for the arrival of the next group of data. Speaking of which, the concept of port still seems abstract. Keep following me and don't go away.
Ports are actually queues, and the operating system assigns different queues to each process. According to the destination port, the packet is pushed into the corresponding queue, waiting to be accessed by the process. Under very special circumstances, this queue may overflow, but the operating system allows each process to specify and adjust its own queue size.
Not only the process receiving the data packet needs to open its own port, but also the process sending the data packet needs to open the port, so that the active port will be identified in the data packet, so that the receiver can smoothly return the data packet to this port.
As the name implies, a gateway is a "gateway" for one network to connect to another.
There are many kinds of gateways according to different classification standards. Gateway in TCP/IP protocol is the most commonly used, here we
The "gateway" refers to the gateway under TCP/IP protocol.
So what exactly is a gateway? A gateway is essentially the IP address of a network to other networks. For example, there are network A and network B. The IP address range of network A is "192.168.1~192.1.254" and the subnet mask is 255 .. Even if two networks are connected to the same switch (or hub), the TCP/IP protocol will determine that the hosts in the two networks are in different networks according to the subnet mask (255.255.255.0). In order to realize the communication between the two networks, it is necessary to pass through the gateway. If the host in network A finds that the destination host of the packet is not in the local network, it will forward the packet to its own gateway, which will then forward the packet to the gateway in network B, which will then forward the packet to the host in network B (as shown in the attached figure). The same is true in the process of network B forwarding packets to network A. Therefore, only by setting the IP address of the gateway can TCP/IP protocol realize communication between different networks. So which machine's IP address is this IP address? The IP address of gateway is the IP address of devices with routing function, including routers, servers with routing protocol enabled (essentially equivalent to routers) and proxy servers (also equivalent to routers).
What is the default gateway?
If you figure out what a gateway is, the default gateway will be easy to understand. Just as a room can have multiple doors,
A host can have multiple gateways. Default gateway means that if the host can't find an available gateway, it will send the packet to the default gateway, and the default gateway will process the packet. The gateway used by the host now usually refers to the default gateway.
How to set the default gateway
The default gateway of the computer cannot be specified casually, but must be specified correctly, otherwise the computer will
The packet is sent to a computer that is not a gateway, so it cannot communicate with computers on other networks. There are two ways to set the default gateway: manual setting and automatic setting.
1. Manual adjustment
Manual setting is suitable for cases where the number of computers is relatively small and the TCP/IP parameters are basically unchanged, such as only a few to a dozen computers.
computer. Because this method needs to set up a "default gateway" on each networked computer, it is very laborious. Once the IP address of the default gateway must be modified due to migration and other reasons, it will bring great trouble to the network management and is not recommended.
In Windows 9x, you can set the default gateway by right-clicking My Network Places, and then clicking in the pop-up menu.
Properties, select TCP/IP protocol in the network properties dialog box, click Properties, and fill in the IP address of the new default gateway in the Default Gateway tab.
It should be noted that the default gateway must be the IP address of the computer's own network segment, and nothing else can be filled in.
IP address in the network segment.
2. Automatic adjustment
Automatic setting is to use DHCP server to automatically assign IP addresses, subnet masks and default gateways to computers in the network.
. The advantage of this is that once the default gateway of the network changes, all computers in the network will get the IP address of the new default gateway as long as the setting of the default gateway in the DHCP server is changed. This method is suitable for networks with large network scale and possible changes in TCP/IP parameters.
Another way to automatically acquire the gateway is to install the client program of proxy server software (such as MS Proxy).
The principle and method are similar to DHCP. Limited to space, I won't go into details.
If you start to look at routing knowledge, it's easy to understand.
Enter command line mode:
c:\ & gt; Routing printing
There will be a route:
0.0.0.0.0.0.0 Default gateway IP interface (IP of the machine) hop count.
Like my machine:
0.0.0.0 0.0.0.0 192. 168. 100.254 192. 168. 100.233 1
Meaning: All packets that need to be forwarded are sent through the IP (interface) of the default gateway, and of course the return is also through there.