使用目的位址NAT實現負載均衡

2021-09-20 20:52:10 字數 3675 閱讀 5062

【實驗拓撲】

【實驗說明】

通常情況下我們內部有多台伺服器,例如web伺服器,這些伺服器的位址不同,但承載的應用時相同的,如何讓外部訪問時實現負載均衡呢?

我們以telnet測試,r1與r6都能夠被telnet。實驗要讓r5訪問r1與r6的telnet服務時,通過nat實現負載均衡

【實驗配置】

r4:inte***ce ethernet 0/0

ip nat inside !

inte***ce serial 0/1

ip nat outside !

inte***ce serial 0/0.1

ip nat outside !

ip nat pool servers prefix-length 24 type rotary

address 10.0.0.1 10.0.0.1

address 10.0.0.6 10.0.0.6

先定義乙個pool,為內部的伺服器位址範圍

!ip access-list extended inbound_telnet

permit tcp any host 150.1.4.4 eq 23

定義允許的服務,和外部訪問內部時被轉換的位址

!ip nat inside destination list inbound_telnet pool servers

設定目的位址nat,實現負載均衡

【實驗驗證】

r4#show ip nat statistics

total active translations: 3 (2 static, 1 dynamic; 1 extended)

outside inte***ces:

serial0/0.1, serial0/1

inside inte***ces:

fastethernet0/0

hits: 480 misses: 12

cef translated packets: 492, cef punted packets: 0

expired translations: 11

-- inside destination

[id: 1] access-list inbound_telnet pool servers refcount 1

pool servers: netmask 255.255.255.0

start 10.0.0.1 end 10.0.0.1

start 10.0.0.6 end 10.0.0.6

type rotary, total addresses 2, allocated 1 (50%), misses 0

queued packets: 0

r5#telnet 150.1.4.4

trying 150.1.4.4 ... open

r1>exit 第一次連線到r1上

[connection to 150.1.4.4 closed by foreign host]

r5#telnet 150.1.4.4

trying 150.1.4.4 ... open

r6>exit 第二次連線到r6上

[connection to 150.1.4.4 closed by foreign host]

r5#

【實驗基本配置】

r1:

inter fa 0/0

ip address 10.0.0.1 255.255.255.0

no shut !

ip route 0.0.0.0 0.0.0.0 10.0.0.4

r4:

inter ethernet 0/0

ip address 10.0.0.4 255.255.255.0

no shut !

inter loopback0

ip add 150.1.4.4 255.255.255.0

ip ospf network point-to-point !

inte***ce serial 0/0

encaps frame-relay

no shutdown !

inte***ce serial 0/0.1 point-to-point

ip address 155.1.0.4 255.255.255.0

frame-relay inte***ce-dlci 405 !

inte***ce serial 0/1

no shutdown

ip address 155.1.45.4 255.255.255.0 !

router ospf 1

router-id 150.1.4.4

network 155.1.0.4 0.0.0.0 area 0

network 155.1.45.4 0.0.0.0 area 0

network 150.1.4.4 0.0.0.0 area 0 !

router bgp 1

bgp router-id 150.1.4.4

neighbor 150.1.5.5 remote-as 2

neighbor 150.1.5.5 update-source loopback0

neighbor 150.1.5.5 ebgp-multihop

r5:

inte***ce loopback0

ip address 150.1.5.5 255.255.255.0

ip ospf network point-to-point !

inte***ce serial 0/0

encapsulation frame-relay

no shut !

inte***ce serial 0/0.1 point-to-point

ip address 155.1.0.5 255.255.255.0

frame-relay inte***ce-dlci 504 !

inte***ce serial 0/1

no shutdown

clockrate 64000

ip address 155.1.45.5 255.255.255.0 !

router ospf 1

router-id 150.1.5.5

network 155.1.0.5 0.0.0.0 area 0

network 155.1.45.5 0.0.0.0 area 0

network 150.1.5.5 0.0.0.0 area 0 !

router bgp 2

bgp router-id 150.1.5.5

neighbor 150.1.4.4 remote-as 1

neighbor 150.1.4.4 update-source loopback0

neighbor 150.1.4.4 ebgp-multihop

neighbor 150.1.4.4 default-originate

r6:

inter gig 0/0

ip address 10.0.0.6 255.255.255.0

no shut !

ip route 0.0.0.0 0.0.0.0 10.0.0.4

NAT高階實驗 實現負載均衡

實驗拓撲如下 公司內部的一台伺服器為公網提供服務,同一時間有多台客戶機同時對該伺服器進行訪問,那麼必然造成該伺服器的負載過高,我們可以通過建立多台相同的伺服器來進行服務的提供,通過nat的負載平衡來解決對單一伺服器資源的消耗 實驗準備,所有的內網位址都可以和公網上的任何乙個ip位址進行通訊,方法略 ...

使用Nginx實現負載均衡

一 nginx 簡介nginx 是乙個高效能的http 伺服器和反向 伺服器。它起初是俄羅斯人igor sysoev 開發的,至今支撐者俄羅斯的很多大型的 二 nginx 支援的三種負載均衡策略 輪詢 將請求依次輪詢發給每個伺服器。ip雜湊 通過雜湊函式決定請求傳送給哪個伺服器。權重 伺服器的權重越...

使用Nginx實現負載均衡

一 nginx 簡介nginx 是乙個高效能的http 伺服器和反向 伺服器。它起初是俄羅斯人igor sysoev 開發的,至今支撐者俄羅斯的很多大型的 二 nginx 支援的三種負載均衡策略 輪詢 將請求依次輪詢發給每個伺服器。ip雜湊 通過雜湊函式決定請求傳送給哪個伺服器。權重 伺服器的權重越...