Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1509462
  • 博文数量: 416
  • 博客积分: 10061
  • 博客等级: 上将
  • 技术积分: 3287
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-05 11:12
个人简介

技术在于专研

文章分类

全部博文(416)

文章存档

2021年(3)

2015年(34)

2013年(2)

2012年(1)

2011年(2)

2010年(5)

2007年(344)

2006年(25)

分类: 系统运维

2007-10-28 14:57:08

单接口NAT配置实例

作者:    

  条件:
  
  1、IOS在12.1(5)T9及以上版本。更低版本未做验证。
  
  2、至少具有两个或多个ISP提供的的global地址。
  
  实现思路:
  
  1、将ISP提供的地址作为secondary地址配置在以太接口上。该以太接口同时作为inside接口。作为内部主机的网关。
  
  2、 创建一个loopback接口做为nat的outside.
  
  3、使用route-map,强行将内部网出去的数据包及从外部返回的对应数据包路由到loopback接口。
  
  实例:
  
  拓朴如下图所示:
  
  配置如下:
  
  interface Loopback0
  
  ip address 172.16.2.254 255.255.255.252
  
  ip nat outside
  
  !
  
  //创建一个loopback接口,并作为NAT outside接口。
  
  interface Ethernet0
  
  ip address 192.168.0.1 255.255.255.248 secondary
  
  ip address 172.16.1.254 255.255.255.0
  
  ip Nat inside
  
  ip policy route-map rm-nat
  
  !
  
  //在E0接口上配置172.16.1.254做为IP,同时将ISP提供的地址做为Secondary地址。e0做为inside接口。
  
  在本接口上应用rm-nat这个route-map
  
  ip nat pool pool1 192.168.0.2 192.168.0.3 prefix-length 29
  
  ip nat inside source list 10 pool pool1 overload
  
  //常规NAT配置
  
  ip classless
  
  ip route 0.0.0.0 0.0.0.0 192.168.0.6
  
  ip route 172.16.1.0 255.255.255.0 Ethernet0
  
  access-list 10 permit 172.16.1.0 0.0.0.255
  
  //配置路由及NAT所需要的access-list
  
  access-list 101 permit ip 172.16.1.0 0.0.0.255 any
  
  access-list 101 permit ip any 192.168.0.0 0.0.0.7
  
  //配置route-map所需要的acl。第一句匹配出去的包,第二句匹配返回的包。
  
  route-map rm-nat permit 10
  
  match ip address 101
  
  set ip next-hop 172.16.2.254
  
  //配置所需要的route-map,凡是满足access-list 101条件的包均被转发到172.16.2.254(loopback0接口)。
  
阅读(2214) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~