How Does Routing Work?
Routers exchange information about what routes exist between them using standard protocols. This article dives into routing and associated concepts.
Join the DZone community and get the full member experience.Join For Free
Routes are created to allow nodes to communicate data packets across networks. In order to route data packets to their destination, they travel along a series of links, each link having a single direction (one-way). A link is formed by joining two adjacent routers together; the router at either end of a link is called the ingress or egress router.
The purpose of routing is to find the best path between two points. Routers exchange information about what routes exist between them using standard protocols. When a packet of data arrives at a router, the router will examine its header to determine where it should send the packet. If the router does not know how to reach the specified destination address, it sends the message to an adjacent router via a neighboring node. Each router stores a table of addresses it knows about. These tables are known as routing tables.
Routes are the paths that allow packets (data) to travel between two different hosts. In TCP/IP networking, routes are defined using IP addresses. IP addresses may have several subnet masks associated with them. Each mask defines how many bits at the end of an IP address represent the host's actual physical location. If a packet comes from a host under a particular subnet mask, then we say that the route of the packet is routed through the router whose interface contains the corresponding subnet. This means that the packet will follow the path of least cost. A subnet mask specifies the range of IP addresses that the router considers to be 'within' its own network.
What Is the Router?
To connect two points together, a router is used. A router is a device that connects computers to networks and routes data between them. Routers are often used to allow computers to communicate over a local area network (LAN) or wide-area network (WAN). The Internet is the largest computer network ever created, connecting billions of devices worldwide. To route information to the Internet, we use routers.
What Is the Internet?
The Internet is the world’s largest system of interconnected public and private computer networks. It consists of millions of individual computer networks, including academic, business, government, multi-national organizations, and residences. Connecting these networks allows users to share information and collaborate online. The Internet uses the Transmission Control Protocol/Internet Protocol (TCP/IP) protocol suite to transfer data across a network. TCP/IP was developed by the United States Department of Defense's Advanced Research Projects Agency (DARPA) in the 1970s, and has since become a de facto standard for networking applications.
What Is the Server?
A server is a software that manages the storage and distribution of documents, images, video, music, and other kinds of content. Servers provide access to their contents via the World Wide Web, e-mail, File Transfer Protocol (FTP), remote login, and other protocols.
What Is the Client?
A client is a program that requests services from a server. Clients display web pages, send and receive messages, and perform a variety of other tasks. Most browsers are clients; they request certain types of information from servers and display the resulting page.
There are two types of routing. Interior routing takes place within a local area network (LAN), while exterior routing occurs between LANs. Exterior routing can use broadcast messages, multicast, unicast, or any combination of these methods.
Multicasting is a specific type of addressing that allows a single message to be transmitted simultaneously to many recipients. Multicasting makes use of a special Internet Protocol (IP) reserved for this purpose, designated 22.214.171.124–126.96.36.199.
Network Address Translation (NAT)
Network Address Translation (NAT), often referred to simply as NAT, is a type of Internet firewall that translates private IP addresses inside private networks to public ones outside those networks. NAT devices maintain state information about both internal and external connections, allowing each connection to be mapped to only one public IP address at a time. This is accomplished by splitting a single IP address space into multiple smaller spaces (subnets) and translating between these subnets inside the device. If two computers are connected together by a cable modem, they would appear to each other as having a unique public IP address. However, behind the scenes, each computer would actually share the same IP address. To make sure data sent across the Internet gets to the right place, routers use Network Address Translation (NAT) to translate the computer's private IP address into the public IP address.
Configuring Port Forwarding
Port forwarding refers to configuring a router to forward traffic on certain ports to a specified local machine or service. This is useful in cases where a client wants to access a server located on the internet but doesn't want to expose their own computer's real IP address. Instead, they create a virtual port forwarding rule which tells the router to send any requests received on a specific port to the desired destination.
What Is the Port Trigger?
A port trigger refers to setting up a custom script that runs whenever a specific port is being accessed. By default, the scripts are run automatically once per hour; however, you can configure your system to run scripts continuously or to execute scripts after receiving a specific number of connections. You can also set triggers to respond to certain conditions, such as incoming SSH connections, or connections coming from a list of IP addresses. You can also write your own scripts that perform complex tasks, including filtering out malicious traffic or blocking unwanted applications.
Things to Remember During Routing
How to Route
```cisco router configuration
clear ip route 0.0.0.0 0.0.0 255.255.255.255 192.168.10.1
clear ip route 172.16.0.0 255 4096 2001:db8::1
ip route command clears the default gateway to avoid sending packets to the wrong destination. The commands above clear the routes to the internet gateway and to our private network.
Add the Static Routes
To add static routes to one or more interfaces, use the following syntax below:
For example, if you want to forward the traffic between two networks, you would use the command as mentioned below:
Published at DZone with permission of Sourav Khanna. See the original article here.
Opinions expressed by DZone contributors are their own.