环境:小凡模拟器.
设备:3台路由器(3640)1台交换机(3640)
IOS:C3640-JSX-M.bin
介绍:
将其中两台路由器作PC1PC2,记住一定要关闭路由功能,否则实验不成功。因为他们会查路由表,而路由表没有另一个vlan的路由,所以不能ping通!
PC1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is not set
 
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.20.0 is directly connected, FastEthernet0/0
(:PC1如果没有关闭路由功能,它有自已的路由表,所以不能pingPC2-172.16.30.254),因此必须要关闭两台PC的路由功能!
 
Router配置:
Ip routing
interface FastEthernet0/0
 no ip address
no shutdown
!
interface FastEthernet0/0.20
 encapsulation dot1Q 20
 ip address 172.16.20.1 255.255.255.0
!
interface FastEthernet0/0.30
 encapsulation dot1Q 30
 ip address 172.16.30.1 255.255.255.0
 
=========================
 
Switch配置:
interface FastEthernet0/0
 switchport mode trunk
 no shutdown
!
interface FastEthernet0/2
 switchport access vlan 20
 no shutdown
!
interface FastEthernet0/3
 switchport access vlan 30
 no shutdown
!
Vlan database
Vlan 20
Vlan 30
Exit
 
=========================
 
PC1配置:
no ip routing
interface FastEthernet0/0
 ip address 172.16.20.254 255.255.255.0
 no shutdown
!
Ip default-gateway 172.16.20.1
 
=========================
 
PC2配置:
no ip routing
interface FastEthernet0/0
 ip address 172.16.30.254 255.255.255.0
 no shutdown
!
Ip default-gateway 172.16.30.1
 
=========================
 
验证:
PC2#ping 172.16.30.254
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.30.254, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 92/136/248 ms
 
 
PC3#ping 172.16.20.254
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.20.254, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 104/128/156 ms