一、背景
最近在線上不同的機房擴容機器時,對同一個域名D
的訪問,在機房A
擴容出來的主機HA
可以訪問,但是在機房B
擴容出來的主機HB
卻無法訪問。
二、問題排查
1、dig排查
在主機HA上dig域名D得到IP:ip_d_ha
在主機HB上dig域名D得到IP:ip_d_hb
2、route路由表查看
在主機HA
上執行route -n
,發現域名D
對應的IP地址ip_d_ha
所在的網段不在主機HA的路由表
裏,但是主機HA的默認路由表有一項默認路由
,示例如下:
在主機HB
執行route -n
,發現域名D
對應的IP地址ip_d_hb
所在的網段既不在主機HB的路由表裏,同時主機HB的默認路由表裏也沒有默認路由。
由此也可得出結論主機HB
不能訪問域名D
是因爲路由表有問題。
三、route命令
route命令用於顯示和維護本機IP路由表,可使用man route
查看詳細幫助文檔。
單獨使用route命令,不帶任何參數時,輸出結果如下:
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.
四、補充
net-toos網絡工具集
在man route
幫忙文檔的最底部,會顯示route命令來源的工具集爲net-tools
,該工具集的homopage。
裏面包含常見的命令:arp, hostname, ifconfig, netstat, rarp, route, plipconfig, slattach, mii-tool and iptunnel and ipmaddr。
該工具集特性如下:
- system tools for linux networking
- used in most Linux distributions