ip Rule showコマンドの数字はどういう意味ですか?

ip Rule showコマンドの数字はどういう意味ですか?

マイコンピュータにコマンドを入力すると、ip rule show結果は次のようになります。

0:  from all lookup local 
32766:  from all lookup main 
32767:  from all lookup default

数字は何をしますか?032766そして32767意味は?

私はこれがいくつかの優先順位です。0特別な優先順位を持ち、削除できません。

また、新しいポリシーを追加すると優先的に作成されます。32765。私の理解は正しいですか?

ip rule addまた、優先順位の内容を見ました。ここ

実際、歴史的な理由により、IP ルールの追加に優先順位の値は必要なく、一意でない値が許可されます。ユーザーが優先順位を提供しない場合、カーネルは優先順位を選択します。ユーザーが作成したルールにすでに存在する優先順位の値がある場合、カーネルは要求を拒否しません。同じ優先順位を持つすべての古いルールの前に新しいルールを追加します。これはデザインのバグでした。これ以上ではありません。そしていつかは修正されるので、この機能に頼らないでください。明確な優先順位を使用してください。

ベストアンサー1

マニュアルページからip-rule:

起動時に、カーネルは3つのルールを含むデフォルトのRPDBを設定します。

   1.  Priority: 0, Selector: match anything, Action: lookup routing 
       table local (ID 255).  The local table is a special routing table 
       containing high priority control routes for local and broadcast 
       addresses.

       Rule 0 is special. It cannot be deleted or overridden.

   2.  Priority: 32766, Selector: match anything, Action: lookup routing 
       table main (ID 254).  The main table is the normal routing table 
       containing all non-policy routes. This rule may be deleted and/or 
       overridden with other ones by the administrator.

   3.  Priority: 32767, Selector: match anything, Action: lookup routing 
       table default (ID 253).  The default table is empty.  It is 
       reserved for some post-processing if no previous default rules 
       selected the packet.  This rule may also be deleted.

  Each RPDB entry has additional attributes.  F.e. each rule has a pointer 
  to some routing table.  NAT and masquerading rules have an attribute to 
  select new IP address to translate/masquerade.  Besides that, rules have 
  some optional attributes, which routes have, namely realms.  These 
  values do not override those contained in the routing tables.  They are 
  only used if the route did not select any attributes.

したがって、この数字0、32766、32767はルールを適用するための優先順位です。

メモ:上記の他の番号255、254、および253は、このファイルに記載されているルーティングテーブルに対応しています。

$ more /etc/iproute2/rt_tables 
#
# reserved values
#
255 local
254 main
253 default
0   unspec
#
# local
#
#1  inr.ruhep

これにより、次のようにルーティングテーブルをクエリするときに上記の名前を使用できます。

$ ip route show table local
broadcast 127.0.0.0 dev lo  proto kernel  scope link  src 127.0.0.1 
local 127.0.0.0/8 dev lo  proto kernel  scope host  src 127.0.0.1 
local 127.0.0.1 dev lo  proto kernel  scope host  src 127.0.0.1 
broadcast 127.255.255.255 dev lo  proto kernel  scope link  src 127.0.0.1 
broadcast 172.17.0.0 dev docker0  proto kernel  scope link  src 172.17.42.1 
local 172.17.42.1 dev docker0  proto kernel  scope host  src 172.17.42.1 
broadcast 172.17.255.255 dev docker0  proto kernel  scope link  src 172.17.42.1 
broadcast 192.168.1.0 dev wlp1s0  proto kernel  scope link  src 192.168.1.80 
local 192.168.1.80 dev wlp1s0  proto kernel  scope host  src 192.168.1.80 
broadcast 192.168.1.255 dev wlp1s0  proto kernel  scope link  src 192.168.1.80 

引用する

おすすめ記事