admin管理员组

文章数量:1635671

linux 路由表

[root@centos6 ~]#route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

192.168.27.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0

0.0.0.0 192.168.27.2 0.0.0.0 UG 0 0 0 eth0

linux 路由表主要字段说明

Destination: 目的地址,可以是主机地址、网络地址,常用的是网络地址

Gateway: 网关地址,所有未知地址都会找网关,有网关统一转发,只有边缘网络才会配置网关,并且直连网络不需要配置网关

Genmask:目的地址的子网掩码

Iface: 接口,去往目的地址的网络路径的出口(也就是从那个出口可以去往目的地址)

官方的原文

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 daemons.

Ref

Number of references to this route. (Not used in the Linux kernel.)

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 segment 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 (possibly 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.

linux 路由配置示例

路由器 R1 路由表

网络ID

子网掩码

接口

网关

10.0.0.0

255.0.0.0

1

-

172.16.0.0

255.255.0.0

2

-

192.168.0.0

255.255.255.0

2

172.16.0.2

192.168.100.0

255.255.255.0

2

172.16.0.2

0.0.0.0

0.0.0.0

2

172.16.0.2

路由器 R2 路由表

连接互联网的路由信息省略 只有边界路由才有 默认路由 0.0.0.0/0.0.0.0 gateway_ip R2 不是边界路由,所以没有默认路由 只有 R1 R3 才有默认路由,可以进行路由合并

网络ID

子网掩码

接口

网关

10.0.0.0

255.0.0.0

3

172.16.0.1

172.16.0.0

255.255.0.0

3

-

192.168.0.0

255.255.255.0

4

-

192.168.100.0

255.255.255.0

4

192.168.0.2

路由器 R3 路由表

网络ID

子网掩码

接口

网关

10.0.0.0

255.0.0.0

5

192.168.0.1

172.16.0.0

255.255.0.0

5

192.168.0.1

192.168.0.0

255.255.255.0

5

-

192.168.100.0

255.255.255.0

6

-

0.0.0.0

0.0.0.0

5

192.168.0.1

本文标签: 路由边界路由表简介Genmask