Skip to main content

RouteD Tables 🌐

 > Routing Tables Explained

The router is a primary component to connect to the internet, but do you know what happens and how it is configured, lets have a peak into Routing Tables.

(img by freepik)

Introduction

Whenever you connect to a website you are not directly connected to the website, for your data to get there it needs to pass through a bunch of routers.

So how do the routers know which path to take? Cuz your router has a bunch of ethernet cables attached to it, how does it choose which road to send your data to?

Scenario

For this example we will go ahead with the following example.


Terminology

Destination → Final destination or the end path or the end IP address of whichever server that you are trying to connect to

Gateway → IP address of your gateway or router (some people refer to routers as gateways, this is cuz your router is a gateway to another network)

Genmask → This is the obvious subnet mask field

Iface → Displays each NIC and WNIC in your computer (usually eth0)

So all the devices in this network have to pass through the router to get to the internet

Flags

  • U → This route is up, hence you can use it as it's up and running
  • G → Gateway, this means that whenever we send data down this route it goes out the door to another network

Practical Example

1) Suppose we try to go to Cisco. By entering its IP

The computer first checks its routing table and decides which path to take.

First, it reads the default one, this means I’m going to look for every other rule to see if this destination matches and if it doesn’t then I’m going to use the default rule so every routing table always has at least a default rule (what you wanna do by default when no other rules match )

It will then check the 2nd row and identify it is the home network so anything starting with this will fall under this category.

The next row has the same set of rules.

Thereby the PC will use the default route. so whenever the PC tries to connect to this website it needs to pass through the default gateway

2) When you want to use the printer on the same network (192.158.0.15)

First, it checks each row of the routing table

Then the table matches the last 2 rows, checks from where it can get them, and realizes it doesn’t need to pass any gateway as it is (*). Because you're not going out any doors to any other networks, this is why it is starred out. Whenever you hit rule and it is starred out, this means that it is always on the same network as you. This is later again clarified against the subnet mask and realizes it falls under the correct subnet, this is also shown by the flags which are displayed as only U.

Then it checks which interface it is supposed to send it on in this case it is eth0 & wlan0. which are the 2 WNICs.

3) What if an IP address matches more than one rule? 192.168.0.15

When this occurs it chooses the rule with the longest subnet mask.

/0 → first rule

/24 → second and third rule

Comments

Popular posts from this blog

Bricks Heist CTF Write-Up 🧱

  > TryHack3M: Bricks Heist ( TryHackMe) Before beginning we need to edit our /etc/hosts file which makes it easier to use the target machine during scanning and exploitation phases.  The /etc/hosts file serves as the first source of hostname-to-IP address mappings before accessing the DNS servers. sudo vim /etc/hosts Thereby if we include our attackbox IP as bricks.thm whenever we access https://bricks.thm in our we browser the atttackbox IP is mapped accordingly. Reconnaissance Nmap We will begin the box by setting up an nmap scan to identify the vulnerable services running on the ports. nmap -sC -sN -oN initialNmap <TARGET-IP> -sC → Default script scanning -sN → This flag specifies a TCP NULL scan. This technique is used to determine whether the ports are open, closed, or filtered by observing the response behavior of the target system. -oN → Instructs Nmap to save the output by this file name The output of this scan does not help us much. When we access the sit...

Sub-Netted 🪐

> Subnetting Explained Introduction Simplified Subnetting , Let’s untangle the knots and dive into the world of networks. Isn't it strange to see the IPv4 address of your laptop and IPv4 address you see on google are actually different ? (img by freepik - vectorsclub) Identification used in the interconnected network. A school identifies their students from admission numbers. Each person has different telephone numbers. Houses have addresses. “Ah Ha, this all revolves around a primary key”. That’s the identification. Likewise the internet has IPv4 addresses. Although they are running out. Incredibly fast… The bearer of IP addresses Routers as we all know are middlemen. These devices are configured by ISP’s in your houses or office, to provide a connection, which enable devices to communicate with the internet, and browse various sources such as Netflix, or eBay. So where’s your IP address ? When you connect to a network such as your home Wi-Fi, each device is provided an IP a...

Everything about DNS servers 🌍

 > DNS (Domain Name System) Introduction Computers as we know communicate and work through binaries, these binaries can be represented in more ways than one such as hexadecimal or denary to mention a few. In a networking context, we have IP addresses that are given to nodes (PCs, smartphones, etc) allowing them to be individually identified within a network. Purpose of a DNS The majority of websites are hosted within a server or the cloud, when accessing their websites our web browser requires the IP address of that server to initiate communication with the target website. Since we know that IP addresses are nothing less than a group of 4 octets separated by a full stop 157.240.22.35, it's difficult for us to type http://157.240.22.35 in the web browser every time we need to access a website such as Facebook. It is this convenience that DNS provides. With the help of DNS, we can enter https://www.facebook.com/ without the need to remember the IP address of Facebook’s server. im...