天天看點

NAT的雙線接入+備份+負載均衡

NAT的雙線接入+備份+負載均衡

----------------------------------------------------------------------------------------------------------------------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

R1:  

Ip add 100.0.0.1255.255.255.252

Ip add 200.0.0.1255.255.255.252

Int f1/0

Ip add192.168.0.1 255.255.255.252

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

route-map cisco3permit 10

match ip address 2

match interface Serial0/1

route-map cisco4permit 10

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

ip policyroute-map load

Int f1/0

Ip nat inside

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:

Vlan database

Vlan 10

Vlan 20

Int f0/0

No switchport

Ip add 192.168.0.2 255.255.255.252

Int vlan 10

Ip add 192.168.10.254 255.255.255.0

Int vlan 20

Ip add 192.168.20.254 255.255.255.0

Ip dhcp pool vlan10

Network 192.168.10.0 255.255.255.0

Default-gateway 192.168.10.254

Ip dhcp pool vlan20

Network 192.168.20.0 255.255.255.0

Default-gateway 192.168.20.254

Int f0/1

Sw a vlan 10

Int f0/2

Sw a vlan 20

Ip route 0.0.0.0 0.0.0.0 192.168.0.1

PC1:

No ip routing

Ip add dhcp

PC2:

Ip add dhcp

----------------------------------------------------------------------------------------------------------------------

先從PC1和PC2上面分别都跟蹤一下路由,看是否起到負載均衡的效果。(看到這種效果就OK了)

NAT的雙線接入+備份+負載均衡

把R1的S0/0或S0/1斷掉在從PC機跟蹤路由看是否起到備份的效果

Down掉S0/0口

NAT的雙線接入+備份+負載均衡

Down掉S0/1口

NAT的雙線接入+備份+負載均衡

這樣既做到了負載均衡又起到了備份的作用!

我試過了,搭好環境直接把指令複制進去就能成功,注意一定要把端口連接配接對了!

Access-list 1permit 192.168.10.0 0.0.0.255----------------------------------定義ACL

route-map loadpermit 10             ----------------------------------定義route-map政策名字随便寫(load)

match ip address1                       ----------------------------------比對前邊定義的ACL

set interfaceSerial0/0                  ----------------------------------比對端口

route-map cisco1permit 10          ----------------------------------定義政策

match ip address 1                            ----------------------------------比對ACL

match interface Serial0/0            --------------------------------跟蹤端口的狀态(UP/DOWN)

match ip address 1                     ----------------------------------這個隻比對ACL就可以了

route-map cisco3permit 10   -----------------------------------下邊這倆和上邊那倆一個意思,隻是比對的ACL和跟蹤的端口不一樣了

如果S0/0端口狀态正常則把cisco1在S0/0端口上做端口複用

如果S0/0端口狀态故障則把cisco2在S0/1端口上做端口複用(其實cisco1和cisco2比對的一個ACL)

如果S0/1端口狀态正常則把cisco3在S0/1端口上做端口複用

如果S0/1端口狀态故障則把cisco4在S0/0端口上做端口複用(其實cisco3和cisco4       比對的是一個ACL)

ip policy route-mapload ----------------------将route-map政策綁定到接口

Int f1/0                        ------------------------定義内外接口

ip route 0.0.0.00.0.0.0 100.0.0.2  -----------------------添加預設路由

繼續閱讀