单臂路由实验

单臂路由是在没有三层交换机的情况下实现VLAN间通信的最基本方法

如图:R1S1之间使用子接口,通过配置单臂路由完成VLAN间路由

S!:

Router>en

Router#conf t

Router(config)#host switch

switch(config)#no ip domai lookup

switch(config)#int f0/1

switch(config-if)#switchport trunk encapsulation dot1q 

switch(config-if)#switchport mode trunk 

switch(config-if)#no shutdown 

switch(config-if)#end

switch#vlan database 

switch(vlan)#vlan 10 name VLAN_A

VLAN 10 added:

    Name: VLAN_A

switch(vlan)#vlan 20 name VLAN_B

VLAN 20 added:

    Name: VLAN_B

switch(vlan)#exit

APPLY completed.

Exiting....

switch#conf t

switch(config)#int f0/2

switch(config-if)#switchport mode access 

switch(config-if)#switchport access vlan 10

switch(config-if)#int f0/3

switch(config-if)#switchport mode access 

switch(config-if)#switchport access vlan 20

switch(config-if)#^Z

switch#

-----------------------

R1:

Router>en

Router#conf t

Router(config)#host R1

R1(config)#no ip domain lookup

R1(config)#int f0/0

R1(config-if)#no shut

R1(config-if)#int f0/0.1 //配置子接口

R1(config-subif)#ip add 192.1.1.1 255.255.255.0

% Configuring IP routing on a LAN subinterface is only allowed if that 

subinterface is already configured as part of an IEEE 802.10, IEEE 802.1Q, 

or ISL vLAN.

R1(config-subif)#encapsulation dot1Q 10 //封装VLAN类型为802.1Q,标签为10

R1(config-subif)#ip add 192.1.1.1 255.255.255.0 //配置IP地址,实际上就是VLAN 10 计算机的网关

R1(config-subif)#no shut

R1(config-subif)#int f0/0.2

R1(config-subif)#encapsulation dot1Q 20

R1(config-subif)#ip add 193.1.1.1 255.255.255.0

R1(config-subif)#no shut

R1(config-subif)#end

R2:

Router>en

Router#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#host R2

R2(config)#int f0/0

R2(config-if)#ip add 192.1.1.2 255.255.255.0

R2(config-if)#no shut

R2(config-if)#ip route 0.0.0.0 0.0.0.0 192.1.1.1

R3

Router>en

Router#conf t

Router(config)#host R3

R3(config)#int f0/0

R3(config-if)#ip add 193.1.1.2 255.255.255.0

R3(config-if)#no shut

R3(config-if)#ip route 0.0.0.0 0.0.0.0 193.1.1.1

*********

测试:

R2#ping 193.1.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 193.1.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 8/34/64 ms

R2#ping 193.1.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 193.1.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/60/128 ms

R2#ping 192.1.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.1.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 8/36/100 ms

R2#

*************

R3#ping 193.1.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 193.1.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 80/168/312 ms

R3#ping 192.1.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.1.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 84/188/424 ms

R3#ping 192.1.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.1.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 400/478/652 ms

R3#

R1#sh 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

C    193.1.1.0/24 is directly connected, FastEthernet0/0.2

C    192.1.1.0/24 is directly connected, FastEthernet0/0.1

R2#sh 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 192.1.1.1 to network 0.0.0.0

C    192.1.1.0/24 is directly connected, FastEthernet0/0

S*   0.0.0.0/0 [1/0] via 192.1.1.1

R3#sh 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 193.1.1.1 to network 0.0.0.0

C    193.1.1.0/24 is directly connected, FastEthernet0/0

S*   0.0.0.0/0 [1/0] via 193.1.1.1