了解netstat -rn的程序
更新記錄
item | note |
---|---|
20160811 | 第一版 |
目錄
netstat
1 | Usage: netstat [-laentuwxrWp] |
netstat -rn
- netstat -rn 及 route -rn 兩個都是相同的結果
- 直接解析/proc/net/route
/proc/net/route
Iface | Destination | Gateway | Flags | RefCnt | Use | Metric | Mask | MTU | Window | IRTT |
---|---|---|---|---|---|---|---|---|---|---|
eth0 | 00000000 | 0116A8C0 | 0003 | 0 | 0 | 0 | 00000000 | 0 | 0 | 0 |
eth0 | 0016A8C0 | 00000000 | 0001 | 0 | 0 | 0 | 00FFFFFF | 0 | 0 | 0 |
- Flags
- An indicator of a number of route attributes
- include/linux/route.h
1 | #define RTF_UP 0x0001 // route usable |
netstat -rn
Kernel IP routing table
Destination | Gateway | Genmask | Flags | MSS | Window | irtt | Iface |
---|---|---|---|---|---|---|---|
0.0.0.0 | 192.168.22.1 | 0.0.0.0 | UG | 0 | 0 | 0 | eth0 |
192.168.22.0 | 0.0.0.0 | 255.255.255.0 | U | 0 | 0 | 0 | eth0 |
Gateway
如果顯示 0.0.0.0 表示該路由是直接由本機傳送,亦即可以透過區域網路的 MAC 直接傳訊Commonly Seen Routing Table Flags
- U
The route is active (up). - H
The route destination is a single host. - G
Send anything for this destination on to this gateway, which will figure out from there where to send it.
需要透過外部的主機 (gateway) 來轉遞封包
- U