session 1 NAT
NAT網(wǎng)絡地址轉(zhuǎn)換,將內(nèi)網(wǎng)用戶私有ip地址轉(zhuǎn)換為公網(wǎng)ip地址實現(xiàn)上網(wǎng)。
簡單的配置分為靜態(tài)NAT、動態(tài)NAT、端口PAT、NAT-server發(fā)布等,下面以實際配置為例:

一、靜態(tài)NAT轉(zhuǎn)換
AR1上配置
interface GigabitEthernet0/0/0
ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 192.168.2.1 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 12.1.1.1 255.255.255.0
nat server global 12.1.1.100 inside 192.168.2.10 在接口下將192.168.2.10轉(zhuǎn)換成12.1.1.100地址訪問公網(wǎng)
nat static enable 啟用nat功能(全局或者接口都可以配置)
#
或者全局下也可以配置靜態(tài)NAT:
[Huawei] nat static global 12.1.1.10 inside 192.168.1.10 netmask 255.255.255.255
AR2上配置
interface GigabitEthernet0/0/0 AR2模擬internet設備,配置公網(wǎng)ip即可
ip address 12.1.1.2 255.255.255.0
#
二、動態(tài)NAT配置
AR1上配置
#
acl number 2000
rule 1 permit source 192.168.1.0 0.0.0.3 使用acl匹配需要進行轉(zhuǎn)換的內(nèi)網(wǎng)ip地址(1.1-1.8這8個ip地址)
#
#
nat address-group 1 12.1.1.10 12.1.1.18 配置nat轉(zhuǎn)換用的公網(wǎng)地址池1,地址范圍12.1.1.10~12.1.1.18
#
interface GigabitEthernet0/0/0
ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1
#
interface GigabitEthernet0/0/2
ip address 12.1.1.1 255.255.255.0
nat outbound 2000 address-group 1 no-pat 在接口出方向上使用動態(tài)NAT,不做PAT端口復用
#
AR2上配置
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
nat static enable
#
三、端口多路復用PAT配置
AR1上的配置
#
acl number 2000 使用acl匹配所有ip流量
rule 1 permit
#
#
interface GigabitEthernet0/0/0
ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 12.1.1.1 255.255.255.0
nat outbound 2000 在出接口上使用PAT端口復用
#
或者可以使用loopback接口(將公網(wǎng)ip配置在loopback接口上)來做PAT接口ip地址,這樣當物理接口ip地址沒有了也不會影響NAT,提高穩(wěn)定性:
[Huawei-GigabitEthernet0/0/2]nat outbound 2000 interface loopback 0
AR2上配置
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
nat static enable
#
驗證可以使用PC2去ping模擬internet的AR2的接口ip:12.1.1.2
PC>ping 12.1.1.2
Ping 12.1.1.2: 32 data bytes, Press Ctrl_C to break
From 12.1.1.2: bytes=32 seq=1 ttl=254 time=47 ms
From 12.1.1.2: bytes=32 seq=2 ttl=254 time=32 ms
From 12.1.1.2: bytes=32 seq=3 ttl=254 time=16 ms
From 12.1.1.2: bytes=32 seq=4 ttl=254 time=31 ms
From 12.1.1.2: bytes=32 seq=5 ttl=254 time=15 ms
--- 12.1.1.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 15/28/47 ms
PC>
四、NAT發(fā)布內(nèi)網(wǎng)服務器到公網(wǎng),供公網(wǎng)用戶訪問。
AR1上配置
#
interface GigabitEthernet0/0/0
ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 12.1.1.1 255.255.255.0
nat server global 12.1.1.100 inside 192.168.1.10 發(fā)布內(nèi)網(wǎng)PC服務器到公網(wǎng),將192.168.1.10發(fā)布到公網(wǎng)使用ip地址12.1.1.100
#
AR2上配置
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
nat static enable
#
測試,使用internet上的AR2來ping發(fā)布的PC的外網(wǎng)ip地址12.1.1.100
[Huawei]ping 12.1.1.100
PING 12.1.1.100: 56 data bytes, press CTRL_C to break
Reply from 12.1.1.100: bytes=56 Sequence=1 ttl=127 time=70 ms
Reply from 12.1.1.100: bytes=56 Sequence=2 ttl=127 time=60 ms
Reply from 12.1.1.100: bytes=56 Sequence=3 ttl=127 time=60 ms
Reply from 12.1.1.100: bytes=56 Sequence=4 ttl=127 time=50 ms
Reply from 12.1.1.100: bytes=56 Sequence=5 ttl=127 time=50 ms
--- 12.1.1.100 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/58/70 ms
[Huawei]
|