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 |
本文鏈接:https://www.cnblogs.com/shichangming/p/10195389.html