Implementation of Policy Routing for multi-network card routing table in Linux

Source: Internet
Author: User

Linux kernel 2.2 starts to support multiple routing tables.
Routing policy Database (RPDB).

Traditional routing table, based on the destination address to do routing. With multiple routing tables, kernel supports policy routing so that it can be routed based on information such as source IP address.

Traditional View route Table command route

New route Table View command IP route

Kernel can define 0 to 255 to identify the routing table.
The file/etc/iproute2/rt_tables need not exist, as the Iproute2 tools has a hard-coded entry for the main table. The route or IP route is a direct view of the main routing table.

The local routing table this routing table is automatically generated and maintained by kernel and should not be changed. The routing table contains local interface routes and broadcast routes, as well as NAT routes.

The main routing table is also automatically generated and maintained by kernel.

Routing Policy Database
The routing policy database controls the order of kernel multiple routing tables. Each rule rule can define a priority between 0 and 32767, and the smaller the number, the higher the priority.
When the routing table cache is empty and the new packet arrives to find the route, kernel begins to look for the highest priority rule0. Kernel repeatedly finds a matching routing rule. If kernel does not find a route in rule, it tries to find the remaining rule.
View Routing rules IP rule show

Ip rule Add unicast iif eth7 prio 32766 table

Delete a route rule
Ip Rule del Prio 32766

IP route flush 10.38.0.0/16 or a route table in which all routes IP route flush table main

IP route Show Cache
IP route Flush Cache

 可在 /etc/sysconfig/network-scripts/route-interface 文件中为每个接口保存其静态路由配置。命令提示符后使用 ip 设定的静态路由会在系统关机或重启后丢失。要配置静态路由以便在系统重启后仍可保留,则必须将其放在 /etc/sysconfig/network-scripts/ 目录中。该文件名的格式应为 route-ifname。route-ifname只是为接口保存的路由配置文件。真正的路由表在rt_tables中定义,定义的路由表各个条目就分散在route-ifname文件中。

Ip rule is the same principle, and the file name format is rule-xx.

/etc/sysconfig/network-scripts/rule-eth0
/etc/sysconfig/network-scripts/route-eth0

Linux multi-NIC multi-card routing table for Policy Routing

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.