NAT概述
-
A類:10.0.0.0 ~ 10.255.255.255
-
B類:172.16.0.0 ~ 172.31.255.255
-
C類:192.168.0.0 ~ 192.168.255.255

NAT技術原理

NAT分類
靜態NAT


#
1
、介面檢視下配置靜態
NAT
[
Huawei
-
GigabitEthernet0
/
0
/
0
] nat
staticglobal
{
global
-address} inside {
host-address }
#
2
、也可以在系統檢視下配置靜態
NAT
[
Huawei
] nat
staticglobal
{
global
-address} inside {
host-address }
# 還要在介面開啟
[
Huawei
-
GigabitEthernet0
/
0
/
0
] nat
static
enable
動態NAT


# 建立地址池,配置公有地址範圍,其中group-index為地址池編號,start-address、end-address分別為地址池起始地址、結束地址
[
Huawei
] nat address-group group-index start-address end-address
# 建立
ACL
,只有匹配上
ACL
才進行
NAT
轉換
[
Huawei
] acl number
[
Huawei
-acl-basic-number ] rule permit source source-address source-wildcard
# 介面檢視下配置帶地址池的
NATOutbound
,no-pat引數指定不進行埠轉換
[
Huawei
-
GigabitEthernet0
/
0
/
0
] nat outbound acl-number address-group group-index [ no-pat ]
# 檢視轉換資訊
dis nat session all
NAPT



# 在動態
NAT
的配置上不新增--no-pat即可
[
R1
-
GigabitEthernet0
/
0
/
1
]nat outbound
2000
address-group
1
-
主機從1024-65535之間範圍起一個埠,如55508
-
目的地為百度www.baidu.com,目的埠http:80,https:443
-
出口地址:111.21.8.5,192.168.1.1:55508–>111.21.8.5:62105 –> www.baidu.com:443
-
出口裝置記錄轉換表項,百度返回資料進行對應的轉換
Easy IP

# 示例,將當前介面地址作為公網地址進行源ip和埠的對映
[
R1
-
GigabitEthernet0
/
0
/
1
]nat outbound
2000
NAT Server


# 進入對應介面
[
R1
]interface
GigabitEthernet0
/
0
/
1
# 配置地址
[
R1
-
GigabitEthernet0
/
0
/
1
]ip address
122.1.2.124
# 指定對映
TCP
/
UDP
協議,指定內網地址和公網地址和埠
[
R1
-
GigabitEthernet0
/
0
/
1
]nat server protocol tcp
global202.10.10.180
inside
192.168.1.18080
典型網路配置實驗

# 核心交換機配置
VLAN
與閘道器地址,下聯交換機配置trunk,上聯路由器配置
ACCESSVLAN30
interface
Vlanif10
ip address
192.168.10.254255.255.255.0
#
interface
Vlanif20
ip address
192.168.20.254255.255.255.0
#
interface
Vlanif30
ip address
10.0.0.2255.255.255.252
#
interface
MEth0
/
0
/
1
#
interface
GigabitEthernet0
/
0
/
1
port link-type access
port
default
vlan
30
#
interface
GigabitEthernet0
/
0
/
2
port link-type trunk
port trunk allow-pass vlan
1020
#
interface
GigabitEthernet0
/
0
/
3
port link-type trunk
port trunk allow-pass vlan
1020
# 配置預設路由指向路由器
ip route-
static0.0.0.00.0.0.010.0.0.1
# 配置介面地址和
NAT
interface
GigabitEthernet0
/
0
/
0
ip address
122.12.1.1255.255.255.252
nat outbound
2000
#
interface
GigabitEthernet0
/
0
/
1
ip address
10.0.0.1255.255.255.252
# 配置路由,向外的預設路由和會內網的靜態路由
ip route-
static0.0.0.00.0.0.0122.12.1.2
ip route-
static192.168.10.0255.255.255.010.0.0.2
ip route-
static192.168.20.0255.255.255.010.0.0.2
#
ACL
acl number
2000
rule
5
permit
# 中間路由器不需要額外配置
interface
GigabitEthernet0
/
0
/
0
ip address
122.12.1.2255.255.255.252
#
interface
GigabitEthernet0
/
0
/
1
ip address
23.12.1.2255.255.255.252
# 配置地址和預設路由
interface
GigabitEthernet0
/
0
/
1
ip address
23.12.1.1255.255.255.252
#
ip route-
static0.0.0.00.0.0.023.12.1.2