What is a gateway
Gateway is the "pass" that connects one network to another network.
According to different classification standards, there are many types of gateways. The gateway in the TCP/IP protocol is the most commonly used. The "gateway" we are talking about here all refer to the gateway under the TCP/IP protocol.
So what is the gateway? A gateway is essentially an IP address that a network leads to other networks. For example, there are network A and network B. The IP address range of network A is "192.168.1.1~192. 168.1.254", and the subnet mask is 255.255.255.0; the IP address range of network B is "192.168.2.1~192.168.2.254", and the subnet mask is 255.255.255.0. In the absence of a router, TCP/IP communication cannot be performed between the two networks. Even if the 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 based on the subnet mask (255.255.255.0). To achieve communication between these two networks, it must 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 forwards the packet to its own gateway, and then forwards it to the gateway of Network B, and the gateway of Network B will forward it to a host of Network B. The same is true for network B forwarding packets to network A.
So, only by setting the IP address of the gateway can the TCP/IP protocol realize mutual communication between different networks. So which machine's IP address is this IP address? The IP address of the gateway is the IP address of the device with routing function. The devices with routing function include a router, a server with routing protocol enabled (essentially equivalent to a router), and a proxy server (also equivalent to a router).
What is the default gateway
If you understand what a gateway is, the default gateway will be easier to understand. Just like a room can have multiple doors, a host can have multiple gateways. The default gateway means that if a host cannot find an available gateway, it sends the packet to the default specified gateway, and this gateway will handle the packet. The gateway used by the host now generally refers to the default gateway.
How to set the default gateway
The default gateway of a computer cannot be specified casually and must be specified correctly, otherwise a computer will send data packets to computers that are not gateways, thus unable to communicate with computers on other networks. There are two ways to set the default gateway: manual settings and automatic settings.
1. Manual settings
Manual settings are suitable for situations where the number of computers is relatively small and the TCP/IP parameters are basically unchanged, such as only a few to more than a dozen computers. Because this method requires setting a "default gateway" on each computer connected to the network, it is very difficult. Once the IP address of the default gateway must be modified due to migration and other reasons, it will cause great trouble to the network management, so it is not recommended to use it.
In Windows 9x, the way to set the default gateway is to right-click on "Online Neighbors", click "Properties" in the pop-up menu, 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 in the network segment where the computer is located, and the IP address in other network segments cannot be filled in.
2. Automatic setting
Automatic setting is to use the 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, as long as the settings of the default gateway in the DHCP server are changed, all computers in the network will obtain the IP address of the new default gateway. This method is suitable for networks with large network sizes and potential changes in TCP/IP parameters.
Another way to automatically obtain the gateway is to automatically obtain it by installing a client program of proxy server software (such as MS Proxy). Its principles and methods are similar to DHCP.