Basic Concepts of Routing

Source: Internet
Author: User
Keywords routing routing meaning routing meaning in networking
This is mainly for some basic concepts of routing under linux.

1 The route is located at L3 (ip layer).

2 The routing table is also called Forwarding Information Base (FIB).

3 The routers exchange information through routing protocols.

4 A routing table contains a lot of routes, a route is to store some necessary information to transmit data packets to a given address. A route in Linux mainly includes these three parameters, which are the destination network address, the equipment to be used, and the next hop gateway.

5 The router will generally be set to the following three situations.
a Different network segments correspond to different network interfaces of the router
b The router has 2 network interfaces on the same lan, and these two network interfaces are configured as different subnets.

6 Symmetric route (symmetric route) and asymmetric route (asymmetric route), in which symmetric route refers to the route taken from HOST a to HOST b and the route taken from HOST b to HOST a are the same, asymmetric The opposite is true.

7 metric is an optional parameter that can be configured to a routing option. Note here that this metric is completely different from the metric in the routing protocol. What is the specific role, I haven't figured it out yet.

8 scope, ip address and routing have the concept of a domain, mainly to tell the kernel the context in which they work. In Linux, the domain of the route indicates the distance between the destination network and the machine. The domain of the ip address indicates the scope of the ip address. There are 3 kinds of scopes in Linux, namely HOST, LINK (for ip address, it means that this address is only used in lan, and for route, the destination address is in lan), Universe/global (wide area network Address, for the route to reach this address, there must be more than 1 hop).

It should be noted that the default value of the domain is Universe, which means that if you do not display the indication, the default is Universe. Below is some information about the routing and ip in my computer.

[diaoliang@T-diaoliang project]$ ip route list
10.13.116.64/26 dev eth0 proto kernel scope link src 10.13.116.71 metric 1
//The default route is Universe, and via represents the gateway address of the next hop.
default via 10.13.116.126 dev eth0 proto static
[diaoliang@T-diaoliang project]$ ip address
1: lo: .....................
.......................
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: ...........................
...............................................
    inet 10.13.116.71/26 brd 10.13.116.127 scope global eth0
    inet6 fe80::225:64ff:fec1:d586/64 scope link
       valid_lft forever preferred_lft forever
9 In a network card with multiple network addresses, before (using ifconfig) you need to set up virtual devices (eth0:0, eth0:1). Now (IPROUTE) directly use ip address to add addresses.

[diaoliang@T-diaoliang ~]$ sudo ip address add 10.13.116.67/26 dev lo
 ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet 10.13.116.67/26 scope global lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
10 Linux uses two routing tables by default, one for local addresses and the other for non-local addresses.

11 action, when the corresponding route (next hop and input device) is obtained from the routing table, the default is to forward the data packet according to the routing information returned. But linux provides an optional action option, this option can be specified when setting with ip. There are 4 types in total, namely:
a Black hole, if this type is matched, the data packet will be dropped.
b Unreachable, if this type is matched, the packet is dropped and an ICMP unreachable message is generated.
c Prohibit, if this type is matched, the data packet will also be dropped, and an ICMP filterd message will be generated.
d Throw, this type is used by policy routing.

12 Routing cache, routing cache will be removed, and multipath cached routing has been removed.

http://git.kernel.org/?p=linux/kernel/git/davem/net-next-2.6.git;a=commitdiff;h=e06e7c615877026544ad7f8b309d1a3706410383

http://comments.gmane.org/gmane.linux.network/185987

13 Route lookup, the steps are like this.
a First look in the cache, if found, route the package to the next hop.
b Then search the local address (routing table of the local address). If found, route the package
c Then look in the non-local routing table.
d If none is found, then drop the data packet.

In the simplest case, for a destination address, only one route will be matched. When complicated, a destination address will return multiple routes. At this time, the kernel will first select the LPM algorithm (Longest Prefix Match), and then explain LPM.

Suppose we have a destination address of 10.0.0.100, and then match 2 routes, 10.0.0.0/16 and 10.0.0.0/24, this time because the second is 24 bits, so the second route will be selected .
There is a more complicated situation, that is, the prefix length of the matched routes is the same, or the above example, if two routes are returned, both are 10.0.0.0/24, but the address of the next hop is different. Therefore, while the kernel uses LPM, it also uses TOS (Type of service) as a key. When tos are the same, the kernel will choose a route with a higher priority. If the priority is also the same, the kernel will choose the first route in order.

14 multipath routing, for a route, provide multiple next hops, the command is as follows:

ip route add default scope globale nexthop via 100.100.100.1 weight 1 nexthop via 200.200.200.1 weight 2
It can be seen that two next hops have been added, and then each has a weight (weight), and the final choice of the nexthop is mainly based on the weight value. The algorithm used by the kernel is not a simple size comparison, it uses a random The algorithm to select nexthop (similar to round-robin).

15 Insert routing information into the kernel, using 3 methods.
a Static config (ip route/ route).
b Use some routing protocols (BGP/EGP/OSPF) for dynamic configuration.
c The kernel receives an ICMP redirect message.

In the b method, a daemon process is run in the user space. This process mainly implements many routing protocols, and then modifies the routing table in the kernel according to the interactive information between the protocols. For example, Routed, GateD, BIRD.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.