全部博文(1015)
分类:
2011-05-10 10:12:20
一、环境准备:router一台(在本实验中我用的是7206呵呵),PC一台
PC的IP:192.168.1.222
loopback0 IP:192.168.0.254
router Primary IP:192.168.1.254
router Secondary IP:192.168.18.9
二、网络拓扑示意图:
三、配置及说明:
interface Loopback0
ip address 192.168.0.254 255.255.255.0
ip nat outside
!
配置loopback0接口,并做为NAT的outside。
interface GigabitEthernet0/1
no ip address
shutdown
duplex auto
speed auto
media-type rj45
no negotiation auto
!
interface GigabitEthernet0/2
no ip address
shutdown
duplex auto
speed auto
media-type rj45
no negotiation auto
!
interface GigabitEthernet0/3
ip address 192.168.18.9 255.255.255.0 secondary
ip address 192.168.1.254 255.255.255.0
ip nat inside
ip policy route-map rm-nat
duplex auto
speed auto
media-type rj45
no negotiation auto
!
配置GigabitEthernet0/3做为NAT的inside接口,配置内部子网网关,并把公网IP做为Secondary地址,并应用route-map“NAT”
ip nat pool pool1 192.168.18.2 192.168.18.3 prefix-length 29
建立NAT地址池pool1
ip nat inside source list 1 pool pool1 overload
引用NAT地址池pool做地址复用
ip classless
ip route 0.0.0.0 0.0.0.0 192.168.18.1
ip route 192.168.1.0 255.255.255.0 GigabitEthernet0/3
路由配置
no ip http server
!
!
access-list 1 permit 192.168.1.0 0.0.0.255
配置ACL控制进行NAT的子网范围
access-list 101 permit ip any 192.168.18.0 0.0.0.7
access-list 101 permit ip 192.168.1.0 0.0.0.255 any
配置route-map使用的ACL控制匹配的数据流
!
route-map nat permit 10
match ip address 101
set ip next-hop 192.168.0.254
配置route-map,满足ACL101的包都转发到loopback0
注:NAT pool的方式也可以采用PAT的方式,在其它网站提供的实验中提到需要2个以上的公网IP才可以实现单端口NAT,在本次实验中测试PAT可行,这样可以节省公网IP,使用一个公网IP即可做单口NAT。
上面兰色部分用下面的配置替代即可。
ip nat inside source list 10 interface GigabitEthernet0/3 overload