DEFAULT GATEWAY - EXPLAINED
Image Credit: Super User

DEFAULT GATEWAY - EXPLAINED

What is a default gateway? That's the subject of this conversation. Now, as a demonstration on a Windows computer, let's check the network configuration. So if you open up a command prompt, and then you type in?ipconfig, in the output, you'll see the?IP address,?subnet mask, and the?default gateway?that's been assigned to your computer. So you might be asking yourself, Well, what is a default gateway? And simply put, a default gateway is a?device?that forwards data from one network to another. And the majority of the time, this is going to be a?router.?

No alt text provided for this image

So for example, in the image below, we have a local area network that comprises the router, switch, and two computers. And on the other side of the router, we have the internet, which is another network. So in order for these computers to access another network, such as a web page out on the internet, the data has to exit its own local network by going through the default gateway, which is the router, and then the router will forward the data to the internet. Now, this also works both ways. So if a device on the internet wanted to communicate with a computer on this network, it has to go through this network's default gateway, and then to the computer.?

Contains 2 computers, 1 switch, 1 router and the internet.Image credit: Cloudflare

Image credit: Cloudflare

So in a nutshell, that's what a default gateway is. It lets devices from one network communicate with devices on another network. And as I said before, this is typically going to be a router, a router is the gateway or doorway to every network. And the term?default?means that the designated device is the first option that's looked upon when data needs to exit the network. Now, if these two computers wanted to communicate with each other, they can just talk directly to each other through the switch. And this is because all these computers are on the same network, their data doesn't have to exit the network and go through the default gateway.?

So this brings us to our next question. And that is if these computers wanted to communicate with another computer, how do they know whether that computer is on their own network or if it's on a different network because as I stated before if this computer wants to communicate with a computer on the same network, it can just talk directly to it. But if it wants to communicate with a computer on a different network, it has to go through the default gateway. So again, how does it know and this is where the?IP address?and?subnet mask?come in. An IP address consists of two parts. The first part is the?network address. And the second part is the?host address. So the way to tell which portion belongs to either the network or the host is where the subnet mask comes in. A subnet mask is a number that resembles an IP address, and it reveals how many bits in the IP address are used for the network by masking the network portion of the IP address. So here we have the IP address and subnet mask in binary form.

IP Address? Binary Form

192.168.0.2 11000000.10101000.00000000.00000010

Subnet Mask

255.255.255.0????? 11111111.11111111.11111111.00000000

?So the way to tell which portion of this IP address is the network portion is when the subnet mask binary digit is a one, it will indicate the position of the IP address that defines the network. So we'll underline all the digits in the IP address that line up with the ones in the subnet mask. And when you do this, it will reveal that the first three octets or sets are the network portion, and the remaining is the host portion. So any computer or device on a network where the first three numbers of the IP address are 192.168.0 means that those computers are on the same network, which means that the computers can talk directly to each other without exiting through the default gateway. And then the host portion is what's uniquely assigned to devices such as computers.?

No alt text provided for this image

Image credit: Powercert

So here we have a private network that has been divided into two sub-networks or subnets. A subnet on the left is under 192.168.0 network. And the subnet on the right is on the 192.168.1 network and each subnet has its own default gateway.?

No alt text provided for this image

Image credit: Powercert

Now let's say that computer A wanted to communicate with computer B on this subnet, so computer A is going to check computer B's IP address to see if it's on the same network or not. And as you can tell, the two computers are on the same network because the network portion of the IP addresses which are the first three octets are the same. So computer A now knows that computer B is on the same network. So now for communication to take place, computer A needs computer B's MAC address and it finds this by sending out an?AARP?broadcast out on the network asking computer B for its MAC address. And once it has the MAC address communication can finally take place.

No alt text provided for this image

Image credit: Powercert

So in another scenario, let's say that computer A on this subnet here wanted to communicate with computer D on this subnet. So again, computer A is going to check computer D's IP address to see if it's on the same network or not. And as you can tell, this time, the two computers are on different networks because the network portion of the IP addresses which are the?first three octets?are different. And a difference is the?third number. Computer A is using a zero and computer D is using a one. So computer A now knows that computer D is on a different network, so it can't directly communicate with it, it has to use the?default gateway. So computer A will send out an?AARP?broadcast. And this time, it'll ask for the MAC address of the default gateway and not the computer because computer D is on a different network and it won't receive the broadcast because?AARP broadcast cannot go past a router. Then once it has the MAC address, it'll send the data to the default gateway, and then it'll be forwarded to the destination.?

So everyone that concludes this article on default gateways.?

Raman M Bellary

SW Test Engineer @ Baxter

2 个月

Insightful

回复
Nosa Aiwuyo

Application Support || Data Analyst||Flexcube

3 年

Thanks for sharing

Taiwo Amao

Technical Support Engineer @ Moniepoint Group ? DevOps ?? ? Cloud Migration ? 5x AWS ? 2x Azure ? Platform Engineer ? AWS Community Builder ??

3 年
回复
Tolani Jaiye-Tikolo (Tito)

Tired of Technical Jargons - RPA? Intelligent Automation? Gen AI? Agentic AI? Follow and be entertained| Top 50 PEX Global Operational Excellence Thought Leader 2023

3 年

Thanks did sharing as always Taiwo

要查看或添加评论,请登录

社区洞察

其他会员也浏览了