華為NAT地址轉換配置,作為網路管理員必須要會的

【實驗原理】

一、中低端NAT配置

1 組網及業務描述

華為NAT地址轉換配置,作為網路管理員必須要會的

路由器RTA作為某中心出口路由器連線外網與內網,實驗環境中,以路由器 RTB來 模擬公網,RTC作為某分支機構也連線到公網。RTA、RTB、RTC公網IP介面之間執行IGP模擬公網環境。透過NAT,RTA所連線的內網使用者可以訪問到公網RTB、RTC。

公網使用者RTB、RTC需要訪問RTA所連線的內網伺服器,實驗環境中,使用路由器RTD模擬內網FTP伺服器。透過NAT地址轉換,RTB、RTC可以訪問到RTA所連線的內網FTP伺服器。

2 命令列列表

華為NAT地址轉換配置,作為網路管理員必須要會的

【實驗步驟】

一、中低端NAT配置

1 配置流程圖

華為NAT地址轉換配置,作為網路管理員必須要會的

2 配置步驟

(1)基本配置:包括埠配置與路由配置。

(2)配置EASY IP方式或IP POOL 方式的NAT地址轉換。首先配置ACL,允許某內網網段, 對於EASY IP方式,直接配置出介面NAT轉換。對於IP POOL,先配置ACL和NAT地址池,之後再配置出介面NAT轉換。

(3)配置NAT Server 的MAP對映

3 結果驗證

(1)首先驗證IGP的連通,即從RTA、RTB、RTC的公網IP可以相互PING通。

(2)在客戶端配置主機的IP地址為192。168。1。0網段,閘道器192。168。1。1。

透過NAT地址轉換,客戶端能夠PING通RTB與RTC。

C:\Documents and Settings\user>ping 10。1。1。2

Pinging 10。1。1。2 with 32 bytes of data:

Reply from 10。1。1。2: bytes=32 time=2ms TTL=254

Reply from 10。1。1。2: bytes=32 time=2ms TTL=254

Reply from 10。1。1。2: bytes=32 time=2ms TTL=254

Reply from 10。1。1。2: bytes=32 time=2ms TTL=254

Ping statistics for 10。1。1。2:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 2ms, Maximum = 22ms, Average = 7ms

C:\Documents and Settings\user>ping 192。2。2。1

Pinging 192。2。2。1 with 32 bytes of data:

Reply from 192。2。2。1: bytes=32 time=43ms TTL=253

Reply from 192。2。2。1: bytes=32 time=23ms TTL=253

Reply from 192。2。2。1: bytes=32 time=23ms TTL=253

Reply from 192。2。2。1: bytes=32 time=23ms TTL=253

Ping statistics for 192。2。2。1:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 23ms, Maximum = 43ms, Average = 28ms

同時在RTA上使用display nat session命令可以看到具體的地址轉換內容。內網地址192。168。1。3:512轉換成10。1。1。6:12288。

display nat session

There are currently 1 NAT session:

Protocol GlobalAddr Port InsideAddr Port DestAddr Port

1 10。1。1。6 12288 192。168。1。3 512 192。2。2。1 512

VPN: 0, status: 11, TTL: 00:01:00, Left: 00:00:59

(3)開啟NAT的除錯開關,將除錯資訊從console口輸出

debugging nat packet

debugging nat event

terminal debugging

除錯資訊如下:

*0。9015814 RTA NAT/8/debug:

(Ethernet0/0-out :)Pro : ICMP

( 192。168。1。3: 512 - 192。2。2。2: 512) ————>

( 10。1。1。6:12288 - 192。2。2。2: 512)

*0。9016010 RTA NAT/8/debug:

(Ethernet0/0-in :)Pro : ICMP

( 192。2。2。2: 512 - 10。1。1。6:12288) ————>

( 192。2。2。2: 512 - 192。168。1。3: 512)

*0。9016779 RTA NAT/8/debug:

(Ethernet0/0-out :)Pro : ICMP

( 192。168。1。3: 512 - 192。2。2。2: 512) ————>

( 10。1。1。6:12288 - 192。2。2。2: 512)

*0。9016970 RTA NAT/8/debug:

(Ethernet0/0-in :)Pro : ICMP

( 192。2。2。2: 512 - 10。1。1。6:12288) ————>

( 192。2。2。2: 512 - 192。168。1。3: 512)

*0。9017769 RTA NAT/8/debug:

(Ethernet0/0-out :)Pro : ICMP

( 192。168。1。3: 512 - 192。2。2。2: 512) ————>

( 10。1。1。6:12288 - 192。2。2。2: 512)

*0。9017960 RTA NAT/8/debug:

(Ethernet0/0-in :)Pro : ICMP

( 192。2。2。2: 512 - 10。1。1。6:12288) ————>

( 192。2。2。2: 512 - 192。168。1。3: 512)

*0。9018759 RTA NAT/8/debug:

(Ethernet0/0-out :)Pro : ICMP

( 192。168。1。3: 512 - 192。2。2。2: 512) ————>

( 10。1。1。6:12288 - 192。2。2。2: 512)

*0。9018950 RTA NAT/8/debug:

(Ethernet0/0-in :)Pro : ICMP

( 192。2。2。2: 512 - 10。1。1。6:12288) ————>

( 192。2。2。2: 512 - 192。168。1。3: 512)

(4)NAT SERVER的驗證

從RTC上,透過訪問RTA的公網地址,達到訪問內網伺服器的目的。內網伺服器為RTD FTP伺服器,驗證如下:

ftp 10。1。1。1

// FTP RTA的地址10。1。1。1訪問192。168。1。2

Trying 10。1。1。1 。。。

Press CTRL+K to abort

Connected to 10。1。1。1。

220 FTP service ready。

User(10。1。1。1:(none)):huawei

331 Password required for huawei。

Password:

230 User logged in。

// 使用RTD上配置的使用者和密碼登陸

[ftp]dir

200 Port command okay。

150 Opening ASCII mode data connection for *。

-rwxrwxrwx 1 noone nogroup 5746199 Oct 10 2002 system

-rwxrwxrwx 1 noone nogroup 952 Oct 31 2005 vrpcfg2。cfg

226 Transfer complete。

FTP: 131 byte(s) received in 0。190 second(s) 689。00 byte(s)/sec。

// 可以看到RTD上的檔案

同時,在RTD上可以看到192。2。2。1的使用者訪問

%Aug 11 11:28:39 2005 RTD FTPS/5/USERIN:User huawei(192。2。2。1)

login succeeded

4 配置參考

(1)基本配置

配置RTA NAT出口路由器

# 配置內網閘道器

[RTA-Ethernet0/1]ip address 192。168。1。1 255。255。255。0

# 配置出介面地址

[RTA-Ethernet0/0]ip addr 10。1。1。1 255。255。255。0

# 配置公網IGP路由

[RTA]interface LoopBack 0

[RTA-LoopBack0]ip addr 1。1。1。1 255。255。255。255

[RTA]router id 1。1。1。1

[RTA]ospf

[RTA-ospf-1]area 0

[RTA-ospf-1-area-0。0。0。0]network 10。1。1。0 0。0。0。255

配置RTB公網路由器

# 配置介面地址

[RTB-Ethernet0/0]ip address 10。1。1。2 255。255。255。0

[RTB-Serial2/0] ip address 192。2。2。2 255。255。255。252

[RTB-LoopBack0]ip address 2。2。2。2 255。255。255。255

# 配置IGP路由

[RTB]router id 2。2。2。2

[RTB]ospf

[RTB-ospf-1]area 0

[RTB-ospf-1-area-0。0。0。0]net 192。2。2。0 0。0。0。3

[RTB-ospf-1-area-0。0。0。0]net 10。1。1。0 0。0。0。255

配置RTC公網路由器

# 配置介面地址

[RTC-Serial3/0]ip addr 192。2。2。1 255。255。255。252

[RTB-LoopBack0]ip address 3。3。3。3 255。255。255。255

# 配置IGP路由

[RTC]router id 3。3。3。3

[RTC]ospf

[RTC-ospf-1]area 0

[RTC-ospf-1-area-0。0。0。0]net 192。2。2。0 0。0。0。3

配置RTD內網FTP伺服器RTD

# 使能FTP SERVER

[RTD]ftp server enable

# 配置FTP使用者

[RTD]local-user huawei password simple Huawei

[RTD]local-user huawei service-type ftp

[RTD]local-user huawei ftp-directory flash:/

# 配置介面與路由

[RTD-Ethernet0/0]ip addr 192。168。1。2 255。255。255。0

[RTD]ip route-static 0。0。0。0 0。0。0。0 192。168。1。1

(2)NAT配置

配置EASY IP方式的NAT

# 配置ACL

[RTA]acl number 2001

[RTA-acl-basic-2001]rule permit source 192。168。1。0 0。0。0。255

[RTA-acl-basic-2001]rule deny

# 配置出介面NAT轉換

[RTA-Ethernet0/0]nat outbound 2001

配置IP POOL方式的NAT

# 配置ACL

[RTA]acl number 2001

[RTA-acl-basic-2001]rule permit source 192。168。1。0 0。0。0。255

[RTA-acl-basic-2001]rule deny

# 配置NAT轉換的地址池

[RTA]nat address-group 1 10。1。1。3 10。1。1。10

# 配置出介面NAT轉換

[RTA-Ethernet0/0]ip addr 10。1。1。1 255。255。255。0

[RTA-Ethernet0/0]nat outbound 2001 address-group 1

配置NAT Server

[RTA-Ethernet0/0]nat server protocol tcp global 10。1。1。1

ftp inside 192。168。1。2 ftp