试验工具:dynamips,IOS:3640
实验拓扑:如图


配置清单:
ROUTER1:
Router#show run
Building configuration...

Current configuration : 577 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname Router
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
!
!
ip cef
!
!
!
!
!        
!
interface FastEthernet0/0
 no ip address
 duplex auto
 speed auto
!
interface FastEthernet0/0.1
 encapsulation dot1Q 10
 ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.2
 encapsulation dot1Q 20
 ip address 192.168.2.1 255.255.255.0
!
ip http server
!
!
!
!
!
control-plane
!
!        
line con 0
line aux 0
line vty 0 4
!
end
-----------------------------------------------------------------------------------
SWITCH:
Router#show run
Building configuration...

Current configuration : 937 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname Router
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
!
!
ip cef
!
!
!
!
!        
!
interface FastEthernet0/0
 switchport mode trunk
!
interface FastEthernet0/1
 switchport access vlan 10
 duplex full
 speed 100
!
interface FastEthernet0/2
 switchport access vlan 20
 duplex full
 speed 100
!
interface FastEthernet0/3
!
interface FastEthernet0/4
!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
!
interface FastEthernet0/11
!
interface FastEthernet0/12
!
interface FastEthernet0/13
!
interface FastEthernet0/14
!
interface FastEthernet0/15
!
interface Vlan1
 no ip address
!
ip http server
!
!        
!
!
!
control-plane
!
!
line con 0
line aux 0
line vty 0 4
!
end
-----------------------------------------------------------------------
PC1:
Router#show run

interface FastEthernet0/0
 ip address 192.168.1.10 255.255.255.0
 no ip route-cache
 duplex auto
 speed auto
!
ip default-gateway 192.168.1.1
ip http server
-----------------------------------------------------------------------
PC2:
Router#show run

interface FastEthernet0/0
 ip address 192.168.2.10 255.255.255.0
 no ip route-cache
 duplex auto
 speed auto
!
ip default-gateway 192.168.2.1
ip http server
----------------------------------------------------------------------
测试:
PC1 ping PC2
Router#ping 192.168.2.10

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.10, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 204/290/372 ms

PC2 ping PC1
Router#ping 192.168.1.10

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.10, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 104/233/360 ms

成功。
-----------------------------------------------------------------------
实验中遇到的问题:
刚开始交换机和路由器还有PC都配置好后,PC只能ping通自己的网关,但是ping不到另外一个vlan,后来检查了一下配置,发现没什么问题,又到网上找了点资料,发现在这个虚拟环境下面,替代PC机的路由器要用no ip routing命令关闭路由功能。使用该命令后后一切正常,不太理解其中奥秘。。。