作者:網絡白領 實驗指導:鑫飄雪
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,關閉路由功能,設置默認網關,模擬內部服務器;
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
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
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
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
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
Trying 202.96.134.1 ... Open
User Access Verification
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
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負載均衡實驗到此結束。作者網絡白領,未經允許嚴禁轉載。