5

I found the following content in the file: /etc/iproute2/rt_tables

255 local
254 main
253 default
0 unspec
#1 inr.ruhep
126 anycast_test_1
127 anycast_test_2

I did read some documents about rt_tables, but I still can't understand what do the numbers mean, such as: 255,254,254,0,126,127

Do the words(in the right side) represent iptables, such as: local,main,default,unspec,anycast_test1 ... If so, where can I find these tables? I mean is there a file called local or main which would contain some routing items/rules just like a route table in router device.

Jack
  • 173
  • 1
  • 1
  • 7
  • 1
    Have a look at the following [article/page](https://savedlog.com/uncategorized/iproute2-custom-tables-and-rules/). It gives some explanatory examples. – Kapil Apr 16 '19 at 02:24

1 Answers1

6

Do the words(in the right side) represent iptables, such as:

No rt_tables is about different route tables. It is not about netfilter firewalling .

I did read some documents about rt_tables, but I still can't understand what do the numbers mean

The /etc/iproute2/rt_tables file basically allows you to give meaningful names to the route tables. You can reference all the possible tables using just a number, but it is easier to remember and use them if you have a good name. There are a few predefined main=254.

By default the table you will normally look at and manipulate is the 'main' table. So if you run ip route, or ip route show you will get the 'main' table by default. You can do ip route show table main or ip route show table 254 to show the main table. If you don't specify a table when adding or changing routes, this is the one that will be used.

Assuming your box with a single interface with a single address the only 'route' you add would usually be the default gateway, and that would be added to the 'main' table. All the other routes in all the default tables (255,254,253,0) will all be automatically added. That route would usually be configured along with your interface IP.

Docs

sarlacii
  • 199
  • 7
Zoredache
  • 130,897
  • 41
  • 276
  • 420
  • I'm still confused, now that there are router devices for routing in the internet, why does linux server still need another routing table? – Jack Apr 16 '19 at 16:57
  • Basically every computer that runs Internet Protocol has a routing table. Routing is a core feature of IP. The routing table is used to figure out when, and how to send packets through a gateway(router) or to attempt to send via the local layer 2 protocol. Your 'default gateway' is a route for 0.0.0.0/0 traffic. – Zoredache Apr 16 '19 at 17:15