路由器NAT負載均衡實驗過程詳解

原創作品,未經作者授權,嚴禁轉載。 
作者:網絡白領      實驗指導:鑫飄雪
 
 
實驗拓撲圖:
點擊在新窗口查看全圖
實驗環境配置說明:
1.將R1的Fa0/0接口的IP設爲:192.168.2.1/24,S1/2接口的IP設爲:202.96.134.1/24;
2.將R2的S1/2接口的IP設爲:202.96.134.2/24;
3.將R4的Fa0/0接口的IP設爲:192.168.2.4/24,關閉路由功能,設置默認網關,模擬內部服務器;
4.將R5的Fa0/0接口的IP設爲:192.168.2.5/24,關閉路由功能,設置默認網關,模擬內部服務器;
 
 
實驗結果要求:
 
在R1上做NAT負載,使R2 telnet R1的S1/2接口,分別跳轉到模擬內部服務器的R4 、R5;
 
點擊在新窗口查看全圖
R4(config-if)#duplex full
R4(config-if)#ip add 192.168.2.4 255.255.255.0
R4(config-if)#no shut
R4(config-if)#exit
2、在R4上配置用戶密碼和虛擬線路密碼,爲後面的測試telnet服務:
R4(config)#enable password 123456
R4(config)#line vty 0 4
R4(config-line)#password 123456
R4(config-line)#exit
 
R5的配置清單:
1、關閉R5的路由功能,設置默認網關,併爲Fa0/0接口配置IP:
R5(config)#no ip routing
R5(config)#ip default-gateway 192.168.2.1
R5(config)#int fa0/0
R5(config-if)#speed 100
R5(config-if)#duplex full
R5(config-if)#ip add 192.168.2.5 255.255.255.0
R5(config-if)#no shut
R5(config-if)#exit
2、在R5上配置用戶密碼和虛擬線路密碼,爲後面的測試telnet服務:
R5(config)#enable password 123456
R5(config)#line vty 0 4
R5(config-line)#password 123456
R5(config-line)#exit
 
R1的配置清單:
1、爲R1的Fa0/0接口配置IP,並指定該接口爲內部接口:
R1(config)#int fa0/0
R1(config-if)#speed 100
R1(config-if)#duplex full
R1(config-if)#ip add 192.168.2.1 255.255.255.0
R1(config-if)#ip nat inside
R1(config-if)#no shut
R1(config-if)#exit
2、爲R1的S1/2接口配置IP,並指定該接口爲外部接口:
R1(config)#int s1/2
R1(config-if)#ip add 202.96.134.1 255.255.255.0
R1(config-if)#ip nat outside
R1(config-if)#no shut
R1(config-if)#exit
3、在R1上配置NAT負載:
A、創建訪問控制列表,匹配目標地址爲R1的S1/2接口:
R1(config)#access-list 1 permit 202.96.134.1 0.0.0.0

B、創建內部目標地址池,類型設爲循環(rotary)以實現負載均衡分擔:
R1(config)#ip nat pool psx 192.168.2.4 192.168.2.5 netmask 255.255.255.0 type rotary

C、應用地址池,當目標地址匹配時轉換目標地址爲地址池中的內部IP地址:
R1(config)#ip nat inside destination list 1 pool psx
 
以上配置完成後,我們用R2來telnet R1的S1/2接口,我們分別telnet兩次,以觀察負載分擔的情況:
 
R2#telnet 202.96.134.1
Trying 202.96.134.1 ... Open

User Access Verification
Password:
R4>en
Password:
R4#

上面的結果顯示,第一次telnet R1的S1/2接口跳轉到了R4上,我們先掛起該會話,再次telnet R1的S1/2接口:

R2#telnet 202.96.134.1
Trying 202.96.134.1 ... Open

User Access Verification
Password:
R5>en
Password:
R5#

這次telnet結果跳轉到了R5上,說明我們的NAT負載均衡是成功的,現在我們來show ip nat tran 看看輸出結果:

R1#show ip nat tran
Pro Inside global      Inside local       Outside local      Outside global
tcp 202.96.134.1:23    192.168.2.4:23     202.96.134.2:43543 202.96.134.2:43543
tcp 202.96.134.1:23    192.168.2.5:23     202.96.134.2:26912 202.96.134.2:26912

OK,NAT負載均衡實驗到此結束。作者網絡白領,未經允許嚴禁轉載。
 
總結:我的上一篇文章《NAT轉換實驗過程詳解》的考覈點是如何把內部源地址(source)轉換爲外部全局地址(發起方通常是內部),以實現內部PC通過一個公網IP共同上網,今天的實驗《路由器NAT負載均衡實驗過程詳解》主要考覈如何將訪問目標地址(destination)轉換爲內部私有IP地址和如何實現服務器的負載均衡(發起方通常是外部),以實現內部服務器使用私有內部IP地址對外提供服務。(作者網絡白領)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章