ip nat 配置.doc
网络基础实验IP NAT 配置
TIME:2014/4/16 The writer: xiaoming no.1
1.实验需求:
1)两个网络分别为172.16.16.0/24,和192.168.1.0/24分别在vlan2,vlan3中,实现不同vlan间的通信,要求172.16.16.0/24能与edge路由的1.1.1.0/24网络通信,192.168.1.0/24 能与edge路由的1.1.1.0/24 网络通信。
2)在core路由上运营商除链路地址外分配了202.201.112.4,202.201.112.5两个地址,要求内部网络(超过400台)PC内与edge1.1.1.1/24同时通信。不受地址限制。
3)在两台PC上能telnet到edge路由器上,并且源地址为202.201.112.4,或202.201.112.5。
2.实验目的:
1)熟悉单臂路由的配置,掌握单臂路由技术。
2)熟悉NAT的配置,掌握PNAT网络转换技术。
3)掌握访问控制列表的正确调用。
3.实验拓扑:
4.实验操作步骤:
Switch0:
version 12.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!
!
spanning-tree mode pvst
!
interface FastEthernet0/1
switchport mode trunk
!
interface FastEthernet0/2
switchport access vlan 2
switchport mode access
!
interface FastEthernet0/3
!
interface FastEthernet0/4
!
interface FastEthernet0/5
Switch1:
version 12.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!
!
spanning-tree mode pvst
!
interface FastEthernet0/1
switchport mode trunk
!
interface FastEthernet0/2
switchport access vlan 3
switchport mode access
!
interface FastEthernet0/3
Switch2:
version 12.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!
!
spanning-tree mode pvst
!
interface FastEthernet0/1
switchport mode trunk
!
interface FastEthernet0/2
switchport mode trunk
!
interface FastEthernet0/3
switchport mode trunk
Core:
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname core
!
!
spanning-tree mode pvst
!
!
!
!
interface FastEthernet0/0
no ip address
ip nat inside
duplex auto
speed auto
!
interface FastEthernet0/0.2
encapsulation dot1Q 2
ip address 172.16.16.1 255.255.255.0
ip nat inside
!
interface FastEthernet0/0.3
encapsulation dot1Q 3
ip address 192.168.1.1 255.255.255.0
ip nat inside
!
interface FastEthernet0/1
ip address 202.201.112.1 255.255.255.0
ip nat outside
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router rip
version 2
network 172.16.0.0
network 192.168.1.0
network 202.201.112.0
no auto-summary
!
ip nat pool xiaoming 202.201.112.4 202.201.112.5 netmask 255.255.255.0
ip nat inside source list 101 pool xiaoming overload
ip classless
!
!
access-list 101 permit ip 172.16.16.0 0.0.0.255 any
access-list 101 permit ip 192.168.1.0 0.0.0.255 any
Edge:
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname edge
!
!
!
spanning-tree mode pvst
!
!
interface Loopback1
ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
shutdown
!
interface FastEthernet0/1
ip address 202.201.112.2 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router rip
version 2
network 1.0.0.0
network 202.201.112.0
no auto-summary
!
ip classless
!
!
line con 0
!
line aux 0
!
line vty 0 4
password xiaoming
login
!
!
!
End
5.实验心得:
1)实现不同vlan间的通信,一般需要三层交换或者使用单臂路由。在做单臂路由的时候,切记所连物理接口需要开启(no shutdown),与交换机相连一段的trunk封装协议需要匹配,一般为802.1q(dot1q).单臂路由是一个接口实现多个网关的配置,所以需要在该接口上配置逻辑子接口,再配置相应的网关地址。
2)在做NAT网络地址转换的时候,一般需要与访问控制列表连用,来控制内部网络哪些允许通过该路由到外网。转换外网地址。切记在建立访问控制列表后,该访问列表不需要在物理接口下调用,如果在物理接口下调用(ip access-list*** in/out),可能会造成网络不能通信或者地址转换NAT不起效。但是需要在接口下调用ip nat insdie/outside。地址转换才能起效。实现地址的转换。
3)在使用地址转换的时候,我们一般需要在出接口上做PNAT,一个端口地址转换。即使地址池有相应的一段地址可供使用,PNAT也需要启用,做备份之用,在多发流量时实现网络互通。