ip — Manipulate network device, routing and tunnels
The ip is a swiss army knife command. It does many functions like assigning IP addresses to interfaces, for setting up routes and display configurations etc. Read the man page to know more about other options. In this part, we will see some of the Routing Policy DataBase (RPDB) management using IP command. RP replaces longest match rule with RPDB, which select the routes by executing some set of rules. This rules allows matching SRC, DST address, ToS, Interface field of the packet to select the routing rule.
$ ip rule show -- List the rules. # ip rule add from 10.1.1.0/24 table 1 prio 600 -- Route packets from 10.1.1.0/24 according to table 1. # ip rule add iif eth1 table 2 prio 60 -- Route the packets from eth1 according to table 2. # ip rule add iif eth1 to 10.2.1.0/24 table 2 prio 66 -- Double conditions. # ip rule del prio 600 -- Delete the rule #600. # ip rule del iif eth1 -- Delete the matching rule. # ip rule del iif eth1 to 10.2.1.0/24 -- Delete the matching rule. # ip rule flush -- Flush all the rules. (Don't try this).
Read: man ip