Routing, in Czech called směrování, but more often the word routování is used (at least in my surroundings). It is a technique used to connect individual networks (more precisely subnets). The original device intended for routing was the router, but nowadays L3 switches, firewalls, or just servers/computers are widely used. The router forwards communication from one network to another.
The following image shows a simple example of a network where we have subnets A, B, and C. These subnets are interconnected through a router and also to the internet. So if, for example, a station from subnet B wants to communicate with a server in subnet A, it sends data to the router, which ensures delivery to subnet A. If the station wants to communicate with the internet, the router sends the data to another interface.
Dividing the network into subnets is hierarchical, and a router must be present in all connections. In communication, we then proceed upwards in the tree to the nearest layer that connects the given subnets, and then back down. The path length is calculated by the number of hops (each transition from device to device, i.e., the number of routers in the path + 1). A direct connection between two computers is 1 hop long. The term next hop is also used, referring to the address of the next router in the path.
In the next image, I tried to capture this situation. It shows a small (and only schematic) section of a larger network (or the internet). At the leaves of the tree are small routers connected to switches and computers. These routers group into larger ones and so on at several levels. Of course, in practice, larger routers are always redundant to ensure network resilience to failures or for load balancing.
Important terms for routing
- Router
- a device that performs routing
- Routing
- routing, forwarding data between networks
- Route
- the path used, recorded in the routing table
- Routing table
- the routing table contains records of individual paths
- Routing protocol
- a routing protocol is used for directing the routed protocol, determining the best path to the destination, and sending routing information to other routers
- Routed protocol
- a routed protocol is IP, IPX, or Apple Talk
Another occasionally used term that is good to know.
- Router on stick
- a router connected to a switch using a single trunk port - meaning we have only one router and only one link, which puts a heavy load on the router and link and causes problems in case of failure
Classification of routing protocols
Several types of route records are created in the routing table, depending on how they were generated. Packets are then directed by one of the basic routing methods:
- static routing - manually entered paths (records in the routing table), secure and good, but does not reflect changes in network topology
- dynamic routing - the network automatically adapts to changes in topology and traffic, paths are automatically calculated using a routing protocol
- default routing - if no other path exists, the default one is used
Dynamic routing protocols are of two basic types:
- distance-vector routing protocol - routers maintain a routing table with information about the distance (vector) to a given network, periodically sending the routing table to neighbors, who adjust their table and send it further, the best path is calculated using one (number of hops in RIP) or more metrics (link throughput and delay in IGRP). A modified type of distance-vector protocol is the path-vector protocol.
- link-state routing protocol - routers maintain a comprehensive database of network topology (created using LSA), exchange link-state advertisements (LSA), LSA are triggered by an event in the network, also send Hello packets to their surroundings, quickly respond to topology changes, but consume more bandwidth and resources on the router, the metric is complex, the best path is calculated using Dijkstra's algorithm shortest path first (SPF)
Note: There is also a special type that is based on the distance-vector protocol and adds some properties of the link-state protocol, called the hybrid routing protocol or advanced distance-vector protocol. Its only representative is EIGRP.
Furthermore, dynamic protocols are divided according to whether they are intended for deployment within a local network (more precisely within an autonomous system (AS), which can contain several LANs) or operate across networks (connecting AS together).
- interior gateway protocol - IGP - routes within an Autonomous System (AS)
- exterior gateway protocol - EGP - routes between AS
General terms
- Variable Length Subnet Masking (VLSM)
- used in Classless Inter-Domain Routing (CIDR). In this case, we can use different mask sizes within a subnet. For example, we can use subnets 10.0.0.0/26 and 10.0.0.64/28 together.
- Autonomous System - AS (Autonomous System)
- a group of IP networks and routers under the management of one (or more) entities.
- Administrative Distance - AD
- is a property used on routers to determine the best path among multiple routing protocols. It defines the reliability of the protocol and prioritizes better ones with a lower number. In other words, a router can run multiple routing protocols and decides which one to use based on AD. On Cisco routers, we can change the default values.
protocol | Administrative Distance |
---|---|
directly connected interface | 0 |
static route | 1 |
EIGRP | 90 |
IGRP | 100 |
OSPF | 110 |
RIP | 120 |
EGP | 140 |
- Split horizon
- a method used to prevent loops in Distance Vector Routing protocols. It is used in RIP, IGRP, and EIGRP. It works by prohibiting the sending of a routing path back to the interface from which it was learned.
- Hold-down timer
- a method used by routing protocols to prevent unnecessary or premature dissemination of routing paths in an unstable environment (when frequent state changes occur). The router waits a certain time until the network is stable.
Individual routing methods
RIP - Routing Information Protocol
- simple to configure and works everywhere
- for small and medium networks
- RIP 1 does not support VLSM
- wastes bandwidth (high overhead communication)
- slow convergence
- simple metric - number of hops
- sends the entire routing table to its neighbors
- maximum 15 hops
Only the networks directly on this router are defined, the rest are learned through updates. Configuration on Cisco using
SWITCH(config)#router rip SWITCH(config-router)#network 132.43.54.0 SWITCH(config-router)#network 145.65.76.0
IGRP - Interior Gateway Routing Protocol
- proprietary Cisco protocol
- does not support VLSM
- uses cost as a metric, depends on bandwidth and delay
- maximum number of hops 255
Configuration on Cisco router (33 is the AS number)
SWITCH(config)#router igrp 33 SWITCH(config-router)#network 134.43.54.0 SWITCH(config-router)#network 143.56.76.0
EIGRP - Enhanced Interior Gateway Routing Protocol
- proprietary Cisco protocol
- fast convergence
- reduces bandwidth consumption for routing updates
- supports various protocols (AppleTalk, IPX, IP) and VLSM
- metric - bandwidth, delay (possibly also load, reliability)
- routing updates are exchanged only between routers in the same AS
- maximum number of hops 255
- loop-free
Uses neighbor table (information about direct neighbors), topology table (all routing records learned), and routing table (best routes from the topology table).
Configuration on Cisco router (33 is the AS number)
SWITCH(config)#router eigrp 33 SWITCH(config-router)#network 172.16.0.0 SWITCH(config-router)#network 10.0.0.0
OSPF - Open Shortest Path First
- hierarchical system - one or more areas connected to a backbone area (area 0)
- routers send link-state (bandwidth and interface status) information to all neighboring routers in the area
- routers create a topology database, which is a model of the entire area
- the shortest path is calculated from the database using Dijkstra's algorithm and recorded in the routing table
- unlimited number of hops
- designed for large heterogeneous networks
- supports VLSM
Configuration on Cisco router (1 is the process ID, locally significant only)
SWITCH(config)#router ospf 1 SWITCH(config-router)#network 132.43.56.0 0.0.0.255 area 0 SWITCH(config-router)#network 145.54.34.6 0.0.63.255 area 0
Static routing
- used, for example, between an ISP and a company, where there is no need for a complex routing protocol
- a record is entered into the routing table for each network
- no overhead
- only for small networks
Configuration on Cisco router
ip route [destination_network] [mask] [next_hop or exit_interface] [administrative_distance] [permanent] SWITCH(config)#ip route 192.168.50.0 255.255.255.0 192.168.1.1
next_hop is the IP address of the next router in the path, more precisely, it is the address of the interface of the neighboring router that is adjacent to this router,
exit_interface is the name of the local exit interface (e.g., s0) through which the path to the target network leads.
Default routing
- can only be used at the edge of the network, where there is one port leading outside the network
- if no other path is defined to reach the destination, the default route, which is the gateway, is used
Configuration on Cisco router
ip route 0.0.0.0 0.0.0.0 [next_hop or exit_interface] SWITCH(config)#ip route 0.0.0.0 0.0.0.0 62.102.58.12
Routing and Windows
Even workstations, such as those running Windows XP, must make decisions about where to route network data. This is based on how the network cards in the computer are configured. According to this configuration, the routing table is dynamically adjusted. However, the entries in the table can also be manually modified. Based on the routing table, Windows decides through which network card to send certain data.
Basic routes are for the gateway, which is used for data that has no other destination, referred to as the default route. Then there are routes for host and loopback (127.0.0.0/8), which lead to the MS TCP Loopback Interface. There is also a route for multicast (224.0.0.0/4). Lastly, there is a route for the local subnet.
Individual routes have a metric (1 to 9999), which determines their priority. The lower the value, the higher the priority. The route is chosen first to match the destination address as closely as possible. If necessary, the metric is the second criterion.
As I mentioned, routing tables are created and adjusted dynamically based on interfaces. We can manually delete, add, or modify entries, but these changes are lost when the computer is restarted. If we want to create a permanent static route, we must create it as persistent. These routes are then stored in the registry at HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\PersistentRoutes
.
To manipulate the routing table in Windows XP (and other MS OS), the route
command is used. Here are a few usage examples:
route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]] route print // prints the routing table route add 0.0.0.0 mask 0.0.0.0 192.168.12.1 // creates a temporary default route, i.e., gateway route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7 // creates a permanent (persistent) route for 10.41.0.0/16 route delete 10.41.0.0 mask 255.255.0.0 // deletes the entry for 10.41.0.0/16
Windows as a router
Routing, as discussed here, only concerns decisions about where to route traffic generated on this computer. If we want to use the computer as a router, meaning it forwards incoming communication, we must enable this function in the registry.
In the registry at HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters
, we must change the value of the IPEnableRouter
entry to 1
.
Note: I would like to point out that enabling this function should be carefully considered, as it can pose a security risk. This function can connect multiple networks (which is likely the intention in this case), so do not enable it without reason.
Kdyz se uz rozpisujes s prikazy network.. tak bys mohl možná přidat, jak se nastavuje defaultni routa v urcitem protokolu... at to tady mam pohromade ;-) Myslim treba: def inf originate, atd.. Dik za fajn clanky!
Přiznám se, že routingu se v praxi nevěnuji (a co jsem potřeboval, tak jsem vystačil s ip route...). Tento článek přináší informace, které by měli být potřebné pro test na CCNA. Je to hlavně o teorii a ne o příkazech IOSu (těch pár je tu proto, že mě stačily u testu).
zdarec lidi...
mam problem se sdilenym pripojenim ve win xp. router pc prideli adresu, z toho druhyho pc se pingnu na jakoukoliv ip adresu (vcetne DNS serveru), ale webovou adresu mi to nejak nepreklada. firewall mam nastavenej spravne, routing v registrech povolenej...
nejakej cas mi to fungovalo, ale najednou to prestalo a ja uz vazne nevim kde by mohla byt chyba:-(
respond to [3]bobo: Tohle by bylo lepší dát do fóra. Ale těžko se takhle hledá problém. Pokud funguje ping na DNS server, tak bych zkusil nslookup, jestli se připojí k DNS serveru a jestli překládá jména.
Zdravim, clanek je super, jen malinka poznamecka. V clanku se na nekolika mistech pise o EIGRP, ale uvadi se IGRP (chybi pismenko ;-) ). Mozna by to nebylo od veci to {opravit}:
# uvnitř sítě
* RIP1, RIP2, IGRP, OSPF, ISIS, IGRP {EIGRP}
..
* Hybrid Routing - IGRP {EIGRP} - kombinace obojího
respond to [5]Radim: Díky za upozornění, asi se mě při nějakém hromadném upravování ztratilo všude E. Přitom v titlu u abbr na IGRP bylo EIGRP.
Ahoj, bezva clanek! jen snad mala uprava. Ve vsech konfiguracich je na CLI: Switch(config)# .....
routovani leda na L3,jinak by melo byt vsude Router(config)#
kdyz uz jsme u tech routeru .-)
jinak pekny souhrn! diky
respond to [7]MLOK: jestli se nemýlím tak L3 switche umějí i routovat, takže to nebude nějaká chyba, že tam má switch... hodně switchů už dneska dokáže zastoupit i DHCP server, ale využitelnost v praxi na větších sítích nic moc.
next_hop je IP adresa interfacu, přes která je daná cílová síť dostupná,........
tam nie je IP adresa interface-u daneho routra ale IP adresa interface-u "next" routra v ceste.... nie?
respond to [9]kammmo: Samozřejmě máte pravdu, děkuji. Takhle by to byl nesmysl (přitom na začátku článku popisuji next hop).
ja by som potreboval prepojit 3 siete tak, ako znovku boli pristupne, ale aby sa envideli medzi sebou. ako postupovat. poradite niekto, pls ;)
diky
Měl bych dotaz na první obrázek v tomto článku. Je možné propojit subnety A,B,C s tímto adresovaním na malém domácím routeru? Snažil jsem se to rozchodit, kvůli takovému úkolu, takto rozvržené pomocí statického routování, ale nefunguje mi to.
respond to [12]Vít: Nemám zkušenosti s malými routery, ale pokud můžete na jednotlivé porty nastavit IP adresy (což budou GW pro jednotlivé subnety), tak by to chodit mělo. Jedná se o přímo připojené interfacy, takže nepotřebujete ani žádný routovací protokol, ale pouze routovací funkci.
:-)Ve winbdows PC 10.201.40.101 mask 255.255.255.0 gw 10.201.40.1
mám staticky routovat na 10.201.121.192 mask 255.255.255.240 přes 10.201.40.254 na server bez routeru. Jak by vypadal příkaz route -p add ?
dík moc, pomohlo :)
Zdravím, chtěl bych se zeptat, jak se dá router přepnout na switch. Popsat nějaký obecný návod.
pište prosím na meil horno.h@seznam.cz
super clanok, dost mi pomohol pri studiu. stale neviem ci musia byt rutre navzajom spojene aby sa mohol pouzit rutovaci protokol napr ospf alebo sa da nakonfigurovat aj jeden ruter prip tri?
respond to [17]yoseph: Routovací protokoly (jako OSPF) jsou založeny na tom, že si dynamicky vyměňují informace a budují routovací tabulku. Pokud budu mít pouze jeden router, tak ztrácí smysl a stačí mi statické routování.
Zdravim, rad bych se zeptal na jednu vec. Sit je postavena jako hvezda a nikde neni propojena do kruhu. Jaky routovaci protokol pouzit? Ma v tomto pripade smysl uvazovat o OSPF nebo staci staticke routovani? Predem diky za nazor.
respond to [19]Daxxim: Záleží na velikosti a struktuře sítě. Běžná firemní LAN si vystačí se statickým routováním a nepotřebuje vyměňovat informace s dalšími routery. To je v případě, kdy se používá jeden (případně několik napevno zapojených) router. Použití routovacích protokolů nemá význam. Pokud ale jsou v síti desítky routerů nebo se počítá, že se budou často obměňovat, nebo máme řadu poboček, mezi kterými řešíme routování a existuje tam více cest, pak se vyplatí rozjet routovací protokol.
Ahoj,
Ten článek se mi fakt líbí. Díky moc!
Zdravím,
Ve škole to nelze pochopit, odsud se dá pochopit všechno.
Díky moc ;-)
Zdravim,
nevíte, jak by vypadaly routovací tabulky s agregovanými sítěmi za předpokladu, že chceme pokud možno co nejmenší počet záznamů v routovací tabulce?
Děkuji