What is the relationship between IP address and gateway?

Have you ever encountered such a scene:

"My computer can't connect to the Internet. I have an IP address, but why can't I get online?"
"What is this subnet mask and default gateway? It's so confusing..."
Don't worry, this article is here to "solve the mystery". Just read it and you will not be confused next time you set up your network.

1. What is an IP address?

An IP address is like your house number. Without it, the courier can't find you.


In the Internet world, IP addresses (Internet Protocol Addresses) are used to identify the location of each device. Just like the house we live in has an address, the devices on the Internet also need "addresses" to communicate with each other.

For example, your computer IP address may be like this:

This means you are in room 10 in the community of "192.168.1".

2. What is the subnet mask used for?

The subnet mask is used to "divide" and decide who is your neighbor and who is not.
Still using the address 192.168.1.10, if your subnet mask is:

Then your "neighbors" are all devices with IP 192.168.1.X (X is from 1 to 254). You all live in the same community, so you can chat with each other by just saying hello.

3. What is the default gateway?

The gateway is like the front door of the community. If you want to find someone who doesn't live in the community, you have to go out first.
For example, if the IP address of a website you want to visit is 8.8.8.8, which is not in your neighborhood, you must first find a gateway (usually your home router) to "pass the message" to you.

Usually the gateway address will be the first address of your network segment, for example:

It is also your "entry and exit".

4. Window setting example
If you want to manually set the IP address of a device, the following is a reasonable setting:
Remember: IP, mask, and gateway must match a network segment, otherwise you will be like moving to another neighborhood and can't even find the door.

In summary: IP is your address, gateway is your door, and mask determines who your neighbors are.