E0/1
E0/1
E0/1
E0/1
E0/2
E0/2
R1
R2
R3
R4
 nat  地址转换_nat
1.静态NAT
 
R1>  en
R1#  config  t
R1(config)#  no   ip   routing
R1(config)#  ip  default-gateway  192.168.1.1
R1(config)#  int  e0/1
R1(config-if)#  ip  add  192.168.1.2  255.255.255.0
R1(config-if)#  no  shut
R1(config-if)#  ip  add  192.168.1.3  255.255.255.0  sec
R1(config-if)#  ip  add  192.168.1.4  255.255.255.0  sec
R1(config-if)#  ip  add  192.168.1.5  255.255.255.0  sec
R1(config-if)#  end
R1#
 
R2>  en
R2#  config  t
R2(config)#  int  e0/1
R2(config-if)#  ip  add  192.168.1.1   255.255.255.0
R2(config-if)#  no  shut
R2(config-if)#  int  e0/2
R2(config-if)#  ip  add  202.1.1.1  255.255.255.0
R2(config-if)#  no  shut
R2(config-if)#  exit
R2(config)#  ip  route  0.0.0.0  0.0.0.0  202.1.1.2
R2(config)#  ip  nat  inside  source  static  192.168.1.1  193.1.1.1
R2(config)#  ip  nat  inside  source  static  192.168.1.2  193.1.1.2
R2(config)#  ip  nat  inside  source  static  192.168.1.3  193.1.1.3
R2(config)#  ip  nat  inside  source  static  192.168.1.4  193.1.1.4
R2(config)#  ip  nat  inside  source  static  192.168.1.5  193.1.1.5
R2(config)#  int  e0/1
R2(config-if)#  ip  nat  inside
R2(config-if)#  int  e0/2
R2(config-if)#  ip   nat  outside
R2(config-if)#  end
R2#
 
 
R3>  en
R3#  config  t
R3(config)#  int  e0/1
R3(config-if)#  ip  add  192.168.1.1   255.255.255.0
R3config-if)#  no  shut
R3(config-if)#  int  e0/2
R3(config-if)#  ip  add  202.1.1.2  255.255.255.0
R3(config-if)#  no  shut
R3(config-if)#  exit
R3(config)#  ip  route  0.0.0.0  0.0.0.0  202.1.1.1
R3(config)#  ip  nat  inside  source  static  192.168.1.1  195.1.1.1
R3(config)#  ip  nat  inside  source  static  192.168.1.2  195.1.1.2
R3(config)#  ip  nat  inside  source  static  192.168.1.3  195.1.1.3
R3(config)#  ip  nat  inside  source  static  192.168.1.4  195.1.1.4
R3(config)#  ip  nat  inside  source  static  192.168.1.5  195.1.1.5
R3(config)#  int  e0/1
R3(config-if)#  ip  nat  inside
R3(config-if)#  int  e0/2
R3(config-if)#  ip   nat  outside
R3(config-if)#  end
R3#
 
 
R4>  en
R4#  config  t
R4(config)#  no   ip   routing
R4(config)#  ip  default-gateway  192.168.1.1
R4(config)#  int  e0/1
R4(config-if)#  ip  add  192.168.1.2  255.255.255.0
R4(config-if)#  no  shut
R4(config-if)#  ip  add  192.168.1.3  255.255.255.0  sec
R4(config-if)#  ip  add  192.168.1.4  255.255.255.0  sec
R4(config-if)#  ip  add  192.168.1.5  255.255.255.0  sec
R4(config-if)#  end
R4#
 
验证:
(1)       R2R3上使用  #debug  ip  nat  命令
(2)       R1上使用扩展ping   ,目标地标可以是195.1.1.1——195.1.1.5
(3)       R2R3可以看到转换的信息
 
 
 
 
2.动态nat
R2使用动态nat,其他路由器的配置保持不变
R2#  config  t
R2(config)#  no  ip  nat  inside  source  static  192.168.1.1  193.1.1.1
R2(config)#  no  ip  nat  inside  source  static  192.168.1.2  193.1.1.2
R2(config)#  no  ip  nat  inside  source  static  192.168.1.3  193.1.1.3
R2(config)#  no  ip  nat  inside  source  static  192.168.1.4  193.1.1.4
R2(config)#  no  ip  nat  inside  source  static  192.168.1.5  193.1.1.5
R2(config)# 
R2(config)#  access-list  1  permit  192.168.1.0  0.0.0.255
R2(config)#  ip  nat  pool  tom  193.1.1.1  193.1.1.3  netmask  255.255.255.0
R2(config)#  ip  nat  inside  source  list  1  pool  tom
R2(config)#  end
R2#
 
验证:
(1)       R1上使用扩展ping   ,目标地标可以是195.1.1.1——195.1.1.5
(2)       R2R3可以看到转换的信息
(3)       R2上使用 #show  ip  nat  translations  可以查看转换表
(4)       R2上使用 #clear  ip  nat  translations  *  可以清空转换表
 
 
 
======================================================================
3.端口复用
R2使用端口复用,其他路由器的配置保持不变
 
方法一:
 
R2#  config   t
R2(config)#  no  ip  nat  inside  source  list  1  pool  tom
R2(config)#  no  ip  nat  pool  tom  193.1.1.1  193.1.1.3  netmask  255.255.255.0
R2(config)#  ip  nat  pool  tom  193.1.1.1  193.1.1.1  netmask  255.255.255.0
R2(config)#  ip  nat  inside  source  list  1  pool  tom  overload
R2(config)#  end
 
验证:
(1)       R1上使用扩展ping   ,目标地标可以是195.1.1.1——195.1.1.5
(2)       R2R3可以看到转换的信息
(3)       R2上使用 #show  ip  nat  translations  可以查看转换表
(4)       R2上使用 #clear  ip  nat  translations  *  可以清空转换表
 
 
 
方法二:
 
R2#  config   t
R2(config)#  no  ip  nat  inside  source  list  1  pool  tom  overload
R2(config)#  no  ip  nat  pool  tom  193.1.1.1  193.1.1.1  netmask  255.255.255.0
R2(config)#  ip  nat  inside  source  list  1  interface  e0/2   overload
R2(config)#  end
 
验证:
(5)       R1上使用扩展ping   ,目标地标可以是195.1.1.1——195.1.1.5
(6)       R2R3可以看到转换的信息
(7)       R2上使用 #show  ip  nat  translations  可以查看转换表
(8)       R2上使用 #clear  ip  nat  translations  *  可以清空转换表