linux shell route

一、背景

最近在線上不同的機房擴容機器時,對同一個域名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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章