手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网络知识>Cisco技术>列表

单口NAT配置实验(二)

来源:互联网 作者:west263.com 时间:2008-02-23
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

一、环境准备: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

参考文章:

http://www.UltraTechnology.net网站的《单接口NAT配置实例》

http://www.cisco.com网站的《Network Address Translation on a Stick

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!