Computer Networks

Gateways and routing

Easy
10 min

Gateways

A gateway refers to a network device that knows how to exit a subnetwork. It is a router, which is a device that connects multiple different IP networks and routes IP traffic. If a subnetwork does not have a gateway, it cannot access other networks, such as the Internet. You can typically see your own gateway from your network card settings under the default gateway section.

Image of Mac network settings (default gateway is "Router").

Routing

IP routing is a key factor in the functioning of the internet, and it enables communication between different devices and systems worldwide.

The basic principle of routing is to send data packets from one network to another to reach the correct destination. This is done through routing tables, which contain information about routes and addresses between networks. Routing tables are constantly updated using routing protocols to ensure that they can guide traffic in the right direction.

Routing tables

The default gateway is actually just one route in your computer's routing table, where there may well be multiple routes.

Here is an example of the Linux "ip route" command that displays the routing table.

default via 192.168.1.1 dev eth0
10.0.0.0/24 via 192.168.1.2 dev eth0

The output displays two lines. The first line starts with the word "default" and defines the default route. In this case, it means that all unsent packets are forwarded using the router at IP address 192.168.1.1, and the traffic is sent using the "eth0" network interface.

The second line starts with the IP address 10.0.0.0 followed by "/24". This line defines a route to a network that is not directly connected to this device. The "via" section shows the IP address 192.168.1.2, which means that traffic to this network is first routed to the IP address 192.168.1.2 using the "eth0" network interface.

Routing protocols

Routing protocols are a crucial part of IP routing. Static routing and dynamic routing are the two main types of routing.

In static routing, routing tables are configured manually for routes between networks. This means that routing information does not change automatically, but must be set manually. Static routing is suitable for small networks where routing information does not need to be updated frequently.

Dynamic routing, on the other hand, allows for the automatic updating and sharing of routing information between network devices. For this purpose, routing protocols such as RIP, OSPF, and BGP are used. Dynamic routing is suitable for larger networks with multiple routers and networks, as it facilitates the management and updates of routing information.

The most popular routing protocols are RIP (Routing Information Protocol), OSPF (Open Shortest Path First), and BGP (Border Gateway Protocol). These protocols have different features and suitability for different network environments.

RIP (Routing Information Protocol)

  • RIP is one of the oldest routing protocols commonly used in smaller networks.
  • It is based on a distributed approach where routing information is shared between neighboring routers with regular updates.
  • RIP uses hop count metric, which determines the cost of the route for making routing decisions.

OSPF (Open Shortest Path First)

  • OSPF is designed for larger and more complex networks.
  • It uses Dijkstra's algorithm to select the shortest path and distribute routing information.
  • OSPF supports multiple subnets and can adapt to network changes quickly.

BGP (Border Gateway Protocol)

  • BGP is an exterior gateway protocol used in large scale level 1 networks of the internet.
  • It manages routing information between different autonomous systems (AS).
  • BGP uses complex metrics such as route distance and political rules to make routing decisions.

Test your knowledge

What does the routing table contain?

What is the difference between static routing and dynamic routing?

hakatemia pro

Ready to become an ethical hacker?
Start today.

As a member of Hakatemia you get unlimited access to Hakatemia modules, exercises and tools, and you get access to the Hakatemia Discord channel where you can ask for help from both instructors and other Hakatemia members.