----------------------------------------------------------------------------------------------------------------------R0:
Enable
Conf t
Int s0/0
Ip add 100.0.0.2255.255.255.252
No shu
Int s0/1
Ip add 200.0.0.2255.255.255.252
No shut
Exit
Int loopback 1
Ip add 2.2.2.2255.255.255.255
Exit
R1:
Enable
Conf t
Int s0/0
Ip add 100.0.0.1255.255.255.252
No shut
Int s0/1
Ip add 200.0.0.1255.255.255.252
No shut
Int f1/0
Ip add192.168.0.1 255.255.255.252
No shut
Exit
Access-list 1permit 192.168.10.0 0.0.0.255
Access-list 2permit 192.168.20.0 0.0.0.255
route-map loadpermit 10
match ip address1
set interfaceSerial0/0
route-maploadpermit 20
match ip address2
set interfaceSerial0/1
route-map cisco1permit 10
match ip address 1
match interface Serial0/0
route-map cisco2permit 10
match ip address 1
route-map cisco3permit 10
match ip address 2
match interface Serial0/1
route-map cisco4permit 10
match ip address 2
ip nat insidesource route-map cisco1 interface Serial0/0 overload
ip nat insidesource route-map cisco2 interface Serial0/1 overload
ip nat insidesource route-map cisco3 interface Serial0/1 overload
ip nat insidesource route-map cisco4 interface Serial0/0 overload
Int f1/0
ip policyroute-map load
Int f1/0
Ip nat inside
Int s0/0
Ip nat outside
Int s0/1
Ip nat outside
ip route 0.0.0.00.0.0.0 100.0.0.2
ip route 0.0.0.00.0.0.0 200.0.0.2
ip route192.168.10.0 255.255.255.0 192.168.0.2
ip route192.168.20.0 255.255.255.0 192.168.0.2
SW1:
Enable
Vlan database
Vlan 10
Vlan 20
Exit
Conf t
Int f0/0
No switchport
Ip add 192.168.0.2 255.255.255.252
No shut
Int vlan 10
Ip add 192.168.10.254 255.255.255.0
No shut
Int vlan 20
Ip add 192.168.20.254 255.255.255.0
No shut
Exit
Ip dhcp pool vlan10
Network 192.168.10.0 255.255.255.0
Default-gateway 192.168.10.254
Exit
Ip dhcp pool vlan20
Network 192.168.20.0 255.255.255.0
Default-gateway 192.168.20.254
Exit
Int f0/1
Sw a vlan 10
Int f0/2
Sw a vlan 20
Exit
Ip route 0.0.0.0 0.0.0.0 192.168.0.1
PC1:
Enable
Conf t
No ip routing
Int f0/0
Ip add dhcp
No shut
PC2:
Enable
Conf t
No ip routing
Int f0/0
Ip add dhcp
No shut
----------------------------------------------------------------------------------------------------------------------
先从PC1和PC2上面分别都跟踪一下路由,看是否起到负载均衡的效果。(看到这种效果就OK了)
把R1的S0/0或S0/1断掉在从PC机跟踪路由看是否起到备份的效果
Down掉S0/0口
Down掉S0/1口
这样既做到了负载均衡又起到了备份的作用!
我试过了,搭好环境直接把命令复制进去就能成功,注意一定要把端口连接对了!
Access-list 1permit 192.168.10.0 0.0.0.255----------------------------------定义ACL
Access-list 2permit 192.168.20.0 0.0.0.255
route-map loadpermit 10 ----------------------------------定义route-map策略名字随便写(load)
match ip address1 ----------------------------------匹配前边定义的ACL
set interfaceSerial0/0 ----------------------------------匹配端口
route-maploadpermit 20
match ip address2
set interfaceSerial0/1
route-map cisco1permit 10 ----------------------------------定义策略
match ip address 1 ----------------------------------匹配ACL
match interface Serial0/0 --------------------------------跟踪端口的状态(UP/DOWN)
route-map cisco2permit 10
match ip address 1 ----------------------------------这个只匹配ACL就可以了
route-map cisco3permit 10 -----------------------------------下边这俩和上边那俩一个意思,只是匹配的ACL和跟踪的端口不一样了
match ip address 2
match interface Serial0/1
route-map cisco4permit 10
match ip address 2
ip nat insidesource route-map cisco1 interface Serial0/0 overload
如果S0/0端口状态正常则把cisco1在S0/0端口上做端口复用
ip nat insidesource route-map cisco2 interface Serial0/1 overload
如果S0/0端口状态故障则把cisco2在S0/1端口上做端口复用(其实cisco1和cisco2匹配的一个ACL)
ip nat insidesource route-map cisco3 interface Serial0/1 overload
如果S0/1端口状态正常则把cisco3在S0/1端口上做端口复用
ip nat insidesource route-map cisco4 interface Serial0/0 overload
如果S0/1端口状态故障则把cisco4在S0/0端口上做端口复用(其实cisco3和cisco4 匹配的是一个ACL)
Int f1/0
ip policy route-mapload ----------------------将route-map策略绑定到接口
Int f1/0 ------------------------定义内外接口
Ip nat inside
Int s0/0
Ip nat outside
Int s0/1
Ip nat outside
ip route 0.0.0.00.0.0.0 100.0.0.2 -----------------------添加默认路由
ip route 0.0.0.00.0.0.0 200.0.0.2