Cisco單臂路由

首先咱們瞭解一下什麼是單臂路由:單臂路由是指在路由器的一個接口上經過配置子接口的方式,實現原來相互隔離的不一樣vlan(虛擬局域網)之間的互聯互通。

———————————————————————————————————————————————shell

單臂路由的子接口:

路由器的物理接口能夠被劃分紅多個邏輯接口,這些被劃分後的邏輯接口被形象的稱爲子接口。值得注意的是這些邏輯子接口不能被單獨的開啓或關閉,也就是說,當物理接口被開啓或關閉時,全部的該接口的子接口也隨之被開啓或關閉。安全

單臂路由的優缺點:

vlan能有效分割局域網,實現各網絡區域之間的訪問控制。但現實中,每每須要配置某些vlan之間的互聯互通。好比,例如:你的公司劃分爲領導層、銷售部、財務部、人事部、技術部,併爲不一樣部門配置了不一樣的vlan,部門之間不能相互訪問,有效保證了各部門的信息安全。但常常出現領導層須要跨越Vvlan訪問其餘各個部門,這個功能就由單臂路由來實現。網絡

優勢:實現不一樣vlan之間的通訊,有助理解、學習vlan原理和子接口概念。

缺點:容易成爲網絡單點故障,配置稍有複雜,現實意義不大。

Demo:

在這裏插入圖片描述

sw:

sw#conf t 
sw(config)#no ip routing
sw(config)#vlan 10,20
sw(config-vlan)#ex      
sw(config)#int f1/1
sw(config-if)#sw mo acc
sw(config-if)#sw acc vlan 10
sw(config-if)#int f1/2
sw(config-if)#sw mo acc 
sw(config-if)#sw acc vlan 20
sw(config-if)#do show vlan-sw b

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa1/0, Fa1/3, Fa1/4, Fa1/5
                                                Fa1/6, Fa1/7, Fa1/8, Fa1/9
                                                Fa1/10, Fa1/11, Fa1/12, Fa1/13
                                                Fa1/14, Fa1/15
10   VLAN0010                         active    Fa1/1
20   VLAN0020                         active    Fa1/2
1002 fddi-default                     act/unsup 
1003 token-ring-default               act/unsup 
1004 fddinet-default                  act/unsup 
1005 trnet-default                    act/unsup 
sw(config-if)#ex  
sw(config)#int f1/0
sw(config-if)#sw mo t
sw(config-if)#sw t en dot
sw(config-if)#do show int f1/0 switchport
Name: Fa1/0
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: Disabled
Access Mode VLAN: 0 ((Inactive))
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active: 1,10,20
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none 
Appliance trust: none

R1配置單臂路由:

R1#conf t
R1(config)#int f0/0.1       //配置子接口1
R1(config-subif)#encapsulation dot1Q 10         //在vlan10中封裝協議
R1(config-subif)#ip add 192.168.10.1 255.255.255.0          //劃分IP地址和子網
R1(config-subif)#no shut        //激活端口
R1(config-subif)#ex
R1(config)#int f0/0.2       //配置子接口2
R1(config-subif)#encapsulation dot1Q 20         //在vlan20中封裝協議
R1(config-subif)#ip add 192.168.20.1 255.255.255.0          //劃分IP地址和子網
R1(config-subif)#no shut        //激活端口
R1(config-subif)#ex
R1(config)#int f0/0 
R1(config-if)#no shut
R1(config-if)#end
R1#show ip int b
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  up                    up      
FastEthernet0/0.1          192.168.10.1    YES manual up                    up      
FastEthernet0/0.2          192.168.20.1    YES manual up                    up      
FastEthernet0/1            unassigned      YES unset  administratively down down    
R1#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

C    192.168.10.0/24 is directly connected, FastEthernet0/0.1
C    192.168.20.0/24 is directly connected, FastEthernet0/0.2
//兩個直連網段在這裏

主機配置IP地址:

PC1> ip 192.168.10.10 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.10 255.255.255.0 gateway 192.168.10.1

PC2> ip 192.168.20.20 192.168.20.1
Checking for duplicate address...
PC1 : 192.168.20.20 255.255.255.0 gateway 192.168.20.1

測試互通並用Wireshark抓包:

PC1> ping 192.168.20.20                                   
192.168.20.20 icmp_seq=1 timeout
84 bytes from 192.168.20.20 icmp_seq=2 ttl=63 time=23.683 ms
84 bytes from 192.168.20.20 icmp_seq=3 ttl=63 time=17.958 ms
84 bytes from 192.168.20.20 icmp_seq=4 ttl=63 time=18.883 ms
84 bytes from 192.168.20.20 icmp_seq=5 ttl=63 time=20.704 ms
//此時是可以ping通的,說明單臂路由配置成功
源IP是10.10,目標IP是20.20,此時通過交換機判斷是vlan10端口傳過來的信息,就會給它打上ID:10的標籤,此時抓包咱們就會看到

在這裏插入圖片描述

R1查看路由表以後知道傳輸給20段,此時會作標籤的轉換,由原來的ID:10變成ID:20

在這裏插入圖片描述

相關文章
相關標籤/搜索