ROUTE(8) Linux Programmer’s Manual ROUTE(8)
名前
route - IP 経路テーブルの表示/設定
書式
route [-CFvnee]
route [-v] [-A family] add [-net|-host] target [netmask Nm] [gw Gw]
[metric N] [mss M] [window W] [irtt I] [reject] [mod] [dyn]
[reinstate] [[dev] If]
route [-v] [-A family] del [-net|-host] target [gw Gw] [netmask Nm]
[metric N] [[dev] If]
route [-V] [--version] [-h] [--help]
説明
route はカーネルの IP 経路テーブルを操作する。その主な目的は、特定の ホ
ス トやネットワークへの静的な経路を設定することである。経路に用いるイン
ターフェースは、このコマンドの前に ifconfig(8) で設定しておく必要がある
。
add または del オプションを使うと、 route は経路テーブルを変更できる。
これらのオプションを指定しない場合、 route は現在の経路テーブルの内容を
表示する。
オプション
-A family
指定したアドレスファミリーを使う (例えば ‘inet’ を指定する。全リ
ストを表示するには ‘route --help’ を使うこと)。
-F カーネルの FIB (Forwarding Information Base) 経路テーブルを操 作
する。これはデフォルトである。
-C カーネルの経路テーブルを操作する。
-v 操作の際に詳細表示するモードを選択する。
-n ホスト名を解決せず、アドレスを数値で表示する。これはネームサーバ
が見つからない場合など、ホスト名の解決ができない場合に有用である
。
-e 経 路テーブルの表示に netstat(8) のフォーマットを使用する。 -ee
は経路情報のすべてのパラメータを 1 行で表示する。
del 経路を削除する。
add 新しい経路を追加する。
target 対象とするネットワークまたはホストを指定する。 10 進ドット表記の
IP アドレスか、ホスト名もしくはネットワーク名を指定可能である。
-net target をネットワークとする。
-host target をホストとする。
netmask NM
ネットワーク経路を追加する場合、そこで使用されるネットマスク。
gw GW ゲートウェイを経由した経路パケット。 注意: 記述されたゲートウェ
イは、まず到達可能でなければならない。これは通常、前もってゲート
ウェイに静的経路を設定しなくてはならないということである。もし、
ローカルのインタフェースのアドレスを指定した場合は、それはパケッ
ト が通過すべきインタフェースの決定に使用される。これは BSD の手
法にのっとったやり方である。
metric M
経路テーブルのメトリック (経路制御デーモンが使用する) を M に 設
定する。
mss M 指定の経路での接続の TCP 最大セグメントサイズ (MSS) を M バイト
に設定する。デフォルトはデバイス の MTU (Maximum Transmission
Unit, 最大送信単位) からヘッダーを引いたサイズである。また、ネッ
トワークパスの MTU が見つかった場合、小さい方の MTU がデフォルト
に なる。この設定は、ネットワークパスの MTU を見付けることができ
なかった場合 (これは ICMP Fragmentation Needed をブロックして し
ま う、間違って設定されたファイヤーウォールなどのために起こる)、
相手側 TCP パケットを強制的に小さくするために使われる。
window W
指定の経路での接続の TCP ウィンドウサイズを W バイトに設定する。
こ れは一般に AX.25 ネットワークや、連続的に送られるフレームを取
りこぼしてしまうようなドライバーでのみ使用される。
irtt I 指定の経路での TCP 接続の初期ラウンドトリップ時間 (irtt) を I
(1-12000) ミリ秒の範囲で設定する。これは一般的に AX.25 ネットワ
ークでのみ使用される。省略した場合、RFC 1122 でデフォルトとさ れ
ている 300 ミリ秒が使用される。
reject ブロックする経路を設定する。これは経路参照の失敗を強制し、例えば
、デフォルトの経路を使用せずに、ネットワークを使わないようにして
し まう場合などに用いる。これは、ファイアーウォールの設定では"な
い"。
mod, dyn, reinstate
動的な経路や変更経路を設定する。これらのフラグは診断の用途に使わ
れ、一般的には経路制御デーモンによってのみ設定される。
dev If 記述されたデバイスに、経路を関連づけることを強制する。通常カーネ
ルは自分自身でデバイスを決定しようとする (すでにある経路とデバイ
ス の記述、経路がどこに追加されているかによる)。一般的なネットワ
ークでは、これを指定する必要はない。
もし dev If がコマンド・ラインの最後のオプションの場合には、 dev
という語は省略しても良い。他の場合では、経路修飾子の順番 (metric
-netmask - gw - dev) は重要ではない。
例
route add -net 127.0.0.0
ネットマスク 255.0.0.0 で (クラス A のネットワークが、対象アドレ
ス から決定される)、通常のループバックを追加する。それは、 lo デ
バイスに関連づけれられる (このデバイスは ifconfig(8) に前もっ て
設定されていると仮定している)。
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
eth0 経由のネットワーク 192.56.76.x を追加する。ここでの 192.*
はクラス C の IP アドレスなので、クラス C のこのネットマスク修飾
子は必須ではない。この場合 dev という語は省略可能である。
route add default gw mango-gw
デフォルト経路 (適切な経路が他にない場合に使用されるもの) を追加
する。この経路を使用するすべてのパケットは、 "mango-gw" を経由す
る。デバイスは "mango-gw" に到達する上で実際に使用する経路に依存
する。 - "mango-gw" に対する静的経路があらかじめ設定されている必
要がある。
route add ipx4 sl0
"ipx4" に対する経路を SLIP インタフェース経由 ("ixp4" は SLIP ホ
ストであると仮定する) で追加する。
route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4
前述の SLIP インタフェース経路をゲートウェイとして、ネットワーク
"192.57.66.x" を追加する。
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
この設定はわかりにくいので、あえて記述した。これは全てのクラス D
(マルチキャスト) IP の経路が "eth0" を通って行くように設定する。
これはマルチキャスト・カーネルの正しい設定である。
route add -net 10.0.0.0 netmask 255.0.0.0 reject
プライベートネットワーク "10.x.x.x" への経路を拒否 (reject) する
ように設定する。
出力
カーネル経路テーブルの出力は、以下の項目で構成される。
Destination
対象ネットワークもしくはホスト。
Gateway
ゲートウェイのアドレスか、 設定されていないなら ’*’ である。
Genmask
Genmask は対象ネ ッ ト ワ ー ク の ネ ッ ト マ ス ク で あ る 。
’255.255.255.255’ は 、 ホ ス ト が 対象である場合のマスクで、
’0.0.0.0’ は、 デフォルト経路のネットマスクである。
Flags 指定可能なフラグとしては、以下のものがある。
U (経路は 有効になっている)
H (ターゲットは ホストである)
G (ゲートウェイを使用する)
R (回復される動的経路)
D (デーモンもしくは置き換えによる 動的な設定である)
M (経路制御デーモンもしくは置き換えによる 変更である)
A (addrconf により設定されている)
C (キャッシュのエントリーである)
! (拒否 (reject) する経路である)
Metric ターゲットの距離 (通常はホップ数) である。最近のカーネルでは無視
されるが、経路制御デーモンが必要とする可能性がある。
Ref 指定のルートの参照数 (Linux カーネルでは使用しない)。
Use 経路の参照回数である。 -F と -C オプションの使用に依存する。これ
は経路キャッシュが失敗 (-F) とヒット (-C) した回数である。
Iface この経路で使用するインタフェースである。
MSS この経路での TCP 接続のデフォルト最大セグメントである。
Window この経路での TCP 接続のデフォルトのウィンドウ・サイズである。
irtt 初期 RTT (ラウンドトリップ時間) である。カーネルは、(遅いと思 わ
れ る) 返信の待ち時間を含まない最良の TCP プロトコルパラメーター
を推測するために、この値を使う。
HH (キャッシュのみ)
キャッシュされた経路のうちハードウェア・ヘッダー・キャッシュを参
照 するものと ARP エントリの数である。キャッシュされた経路のイン
タフェースがハードウェア・アドレスを必要としない場合 (例えば lo)
では、この値は -1 になる。
Arp (キャッシュのみ)
キャッシュされた経路に対するハードウェアアドレスの更新状況である
。
ファイル
/proc/net/ipv6_route
/proc/net/route
/proc/net/rt_cache
関連項目
ifconfig(8), netstat(8), arp(8), rarp(8)
履歴
Linux 用 の route コ マ ン ド は 、 最 初 に Fred N. van Kempen,
ROUTE(8) Linux Programmer’s Manual ROUTE(8)
NAME
route - show / manipulate the IP routing table
SYNOPSIS
route [-CFvnee]
route [-v] [-A family] add [-net|-host] target [netmask Nm] [gw Gw]
[metric N] [mss M] [window W] [irtt I] [reject] [mod] [dyn]
[reinstate] [[dev] If]
route [-v] [-A family] del [-net|-host] target [gw Gw] [netmask Nm]
[metric N] [[dev] If]
route [-V] [--version] [-h] [--help]
NOTE
This program is obsolete. For replacement check ip route.
DESCRIPTION
Route manipulates the kernel’s IP routing tables. Its primary use is
to set up static routes to specific hosts or networks via an interface
after it has been configured with the ifconfig(8) program.
When the add or del options are used, route modifies the routing
tables. Without these options, route displays the current contents of
the routing tables.
OPTIONS
-A family
use the specified address family (eg ‘inet’; use ‘route --help’
for a full list).
-F operate on the kernel’s FIB (Forwarding Information Base) rout-
ing table. This is the default.
-C operate on the kernel’s routing cache.
-v select verbose operation.
-n show numerical addresses instead of trying to determine symbolic
host names. This is useful if you are trying to determine why
the route to your nameserver has vanished.
-e use netstat(8)-format for displaying the routing table. -ee
will generate a very long line with all parameters from the
routing table.
del delete a route.
add add a new route.
target the destination network or host. You can provide IP addresses in
dotted decimal or host/network names.
-net the target is a network.
-host the target is a host.
netmask NM
when adding a network route, the netmask to be used.
gw GW route packets via a gateway. NOTE: The specified gateway must
be reachable first. This usually means that you have to set up a
static route to the gateway beforehand. If you specify the
address of one of your local interfaces, it will be used to
decide about the interface to which the packets should be routed
to. This is a BSDism compatibility hack.
metric M
set the metric field in the routing table (used by routing dae-
mons) to M.
mss M sets MTU (Maximum Transmission Unit) of the route to M bytes.
Note that the current implementation of the route command does
not allow the option to set the Maximum Segment Size (MSS).
window W
set the TCP window size for connections over this route to W
bytes. This is typically only used on AX.25 networks and with
drivers unable to handle back to back frames.
irtt I set the initial round trip time (irtt) for TCP connections over
this route to I milliseconds (1-12000). This is typically only
used on AX.25 networks. If omitted the RFC 1122 default of 300ms
is used.
reject install a blocking route, which will force a route lookup to
fail. This is for example used to mask out networks before
using the default route. This is NOT for firewalling.
mod, dyn, reinstate
install a dynamic or modified route. These flags are for diag-
nostic purposes, and are generally only set by routing daemons.
dev If force the route to be associated with the specified device, as
the kernel will otherwise try to determine the device on its own
(by checking already existing routes and device specifications,
and where the route is added to). In most normal networks you
won’t need this.
If dev If is the last option on the command line, the word dev
may be omitted, as it’s the default. Otherwise the order of the
route modifiers (metric - netmask - gw - dev) doesn’t matter.
EXAMPLES
route add -net 127.0.0.0
adds the normal loopback entry, using netmask 255.0.0.0 (class A
net, determined from the destination address) and associated
with the "lo" device (assuming this device was prviously set up
correctly with ifconfig(8)).
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
adds a route to the network 192.56.76.x via "eth0". The Class C
netmask modifier is not really necessary here because 192.* is a
Class C IP address. The word "dev" can be omitted here.
route add default gw mango-gw
adds a default route (which will be used if no other route
matches). All packets using this route will be gatewayed
through "mango-gw". The device which will actually be used for
that route depends on how we can reach "mango-gw" - the static
route to "mango-gw" will have to be set up before.
route add ipx4 sl0
Adds the route to the "ipx4" host via the SLIP interface (assum-
ing that "ipx4" is the SLIP host).
route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4
This command adds the net "192.57.66.x" to be gatewayed through
the former route to the SLIP interface.
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
This is an obscure one documented so people know how to do it.
This sets all of the class D (multicast) IP routes to go via
"eth0". This is the correct normal configuration line with a
multicasting kernel.
route add -net 10.0.0.0 netmask 255.0.0.0 reject
This installs a rejecting route for the private network
"10.x.x.x."
OUTPUT
The output of the kernel routing table is organized in the following
columns
Destination
The destination network or destination host.
Gateway
The gateway address or ’*’ if none set.
Genmask
The netmask for the destination net; ’255.255.255.255’ for a
host destination and ’0.0.0.0’ for the default route.
Flags Possible flags include
U (route is up)
H (target is a host)
G (use gateway)
R (reinstate route for dynamic routing)
D (dynamically installed by daemon or redirect)
M (modified from routing daemon or redirect)
A (installed by addrconf)
C (cache entry)
! (reject route)
Metric The ’distance’ to the target (usually counted in hops). It is
not used by recent kernels, but may be needed by routing dae-
mons.
Ref Number of references to this route. (Not used in the Linux ker-
nel.)
Use Count of lookups for the route. Depending on the use of -F and
-C this will be either route cache misses (-F) or hits (-C).
Iface Interface to which packets for this route will be sent.
MSS Default maximum segement size for TCP connections over this
route.
Window Default window size for TCP connections over this route.
irtt Initial RTT (Round Trip Time). The kernel uses this to guess
about the best TCP protocol parameters without waiting on (pos-
sibly slow) answers.
HH (cached only)
The number of ARP entries and cached routes that refer to the
hardware header cache for the cached route. This will be -1 if a
hardware address is not needed for the interface of the cached
route (e.g. lo).
Arp (cached only)
Whether or not the hardware address for the cached route is up
to date.
FILES
/proc/net/ipv6_route
/proc/net/route
/proc/net/rt_cache
SEE ALSO
ip(8)
HISTORY
Route for Linux was originally written by Fred N. van Kempen,
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa