史萊姆論壇

史萊姆論壇 (http://forum.slime.com.tw/)
-   網路軟硬體架設技術文件 (http://forum.slime.com.tw/f133.html)
-   -   靜態路由的兩種配置方法 (http://forum.slime.com.tw/thread110882.html)

psac 2004-05-27 05:24 PM

靜態路由的兩種配置方法
 
靜態路由的兩種配置方法

靜態路由有兩種配置方法:
ip route 0.0.0.0 0.0.0.0 next_hop_address
ip route 0.0.0.0 0.0.0.0 output_interface

這兩種配置方法有什麼區別呢?讓我們用一個例子來說明一下:

假設在RT1上配置了如下一條靜態路由——
ip route 0.0.0.0 0.0.0.0 Ethernet1

現在我們ping 4.4.4.3,這個位址不屬於RT1上的任何一個網段,同時開啟debug arp

RT1#debug arp
RT1#ping 4.4.4.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.3, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

RT1#
00:38:27: IP ARP: creating incomplete entry for IP address: 4.4.4.3 interface Ethernet1
00:38:27: IP ARP: sent req src 192.168.168.9 0010.7b37.c0a3,
dst 4.4.4.3 0000.0000.0000 Ethernet1
00:38:27: IP ARP: rcvd rep src 4.4.4.3 00e0.1e3e.717b, dst 192.168.168.9 Ethernet1
!---通過debug的結果可以看到,接頭E1(位址為192.168.168.9)發出了arp request,然後接收到了4.4.4.3的arp replay

再看看arp的結果:
RT1#sh arp
Protocol Address Age (min) Hardware Addr Type Interface
Internet 4.4.4.1 0 00e0.1e3e.717b ARPA Ethernet1
Internet 4.4.4.2 1 00e0.1e3e.717b ARPA Ethernet1
Internet 4.4.4.3 0 00e0.1e3e.717b ARPA Ethernet1
Internet 192.168.168.9 - 0010.7b37.c0a3 ARPA Ethernet1
!---我ping了三個位址,可以看到4.4.4.1/2/3這三個IP位址的MAC位址均為00e0.1e3e.717b,這個MAC位址均為對端路由器乙太網口的MAC位址

RT2#debug arp
00:21:20: IP ARP: rcvd req src 192.168.168.9 0010.7b37.c0a3, dst 4.4.4.2 Ethernet0
00:21:20: IP ARP: creating entry for IP address: 192.168.168.9, hw: 0010.7b37.c0a3
00:21:20: IP ARP: sent rep src 4.4.4.2 00e0.1e3e.717b,
dst 192.168.168.9 0010.7b37.c0a3 Ethernet0
00:21:39: IP ARP: rcvd req src 192.168.168.9 0010.7b37.c0a3, dst 4.4.4.1 Ethernet0
00:21:39: IP ARP: sent rep src 4.4.4.1 00e0.1e3e.717b,
dst 192.168.168.9 0010.7b37.c0a3 Ethernet0
!---在對端路由器上開啟debug arp,可以看到對端路由器對arp request的回應程序

之所以會出現這樣的情況是因為預設情況下路由器乙太網口的proxy arp功能是開啟的:

RT2#sh ip int e0
Ethernet0 is up, line protocol is up
Internet address is 192.168.168.8/24
Broadcast address is 255.255.255.255
Address determined by non-volatile memory
MTU is 1500 bytes
Helper address is not set
Directed broadcast forwarding is enabled - but restricted by access list 10
Multicast reserved groups joined: 224.0.0.9
Outgoing access list is not set
Inbound access list is not set
Proxy ARP is enabled
……

這種靜態路由配置方法所產生的結果就是對每一個外網位址的訪問均會產生一個arp表目,造成arp表項過長,無謂地佔用系統資源,同時造成機器執行不穩定,甚至可能會不定期重啟。

如果採用next hop的配置方法:
ip route 0.0.0.0 0.0.0.0 192.168.168.8

再ping 4.4.4.3

RT1#
00:44:46: IP ARP: creating incomplete entry for IP address: 192.168.168.8 interface Ethernet1
00:44:46: IP ARP: sent req src 192.168.168.9 0010.7b37.c0a3,
dst 192.168.168.8 0000.0000.0000 Ethernet1
00:44:46: IP ARP: rcvd rep src 192.168.168.8 00e0.1e3e.717b, dst 192.168.168.9 Ethernet1
!---對比看看兩種靜態路由配置方式的debug結果有何不同:
00:38:27: IP ARP: rcvd rep src 4.4.4.3 00e0.1e3e.717b, dst 192.168.168.9 Ethernet1

而這時的arp表項中就只含有下一跳位址的MAC位址:

RT1#sh arp
Protocol Address Age (min) Hardware Addr Type Interface
Internet 192.168.168.8 0 00e0.1e3e.717b ARPA Ethernet1
Internet 192.168.168.9 - 0010.7b37.c0a3 ARPA Ethernet1

另外兩種靜態路由的區別

route -p 用來增加Persistent routes
儲存在:
HKEY_LOCAL_MACHINESystemCurrentControlSetServicesTcpipParametersPersistentRoutes
當IP棧啟始化的時候, 路由表就生效了.

而RRAS增加的靜態路由Static routes是儲存在:
HKEY_LOCAL_MACHINESystemCurrentControlSetServicesRemoteAccessInterfaces<Interface Number>InterfaceInfo
只有在RRAS(IP routing protocol) 啟動之後, 這些路由資訊才會進入路由表.


所有時間均為台北時間。現在的時間是 03:26 AM

Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.

『服務條款』

* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *


SEO by vBSEO 3.6.1