单臂路由(router-on-a-stick):
是指在路由器的一个接口上通过配置子接口(或“逻辑接口”,并不存在真正物理接口)的方式,实现原来相互隔离的不同VLAN(虚拟局域网)之间的互联互通。
单臂路由的子接口
路由器的物理接口可以被划分成多个逻辑接口,这些被划分后的逻辑接口被形象的称为子接口。值得注意的是这些逻辑子接口不能被单独的开启或关闭,也就是说,当物理接口被开启或关闭时,所有的该接口的子接口也随之被开启或关闭。
优缺点
VLAN能有效分割局域网,实现各网络区域之间的访问控制。但现实中,往往需要配置某些VLAN之间的互联互通。比如,你的公司划分为领导层、销售部、财务部、人力部、科技部、审计部,并为不同部门配置了不同的VLAN,部门之间不能相互访问,有效保证了各部门的信息安全。但经常出现领导层需要跨越VLAN访问其他各个部门,这个功能就由单臂路由来实现。
优点:实现不同vlan之间的通信,有助理解、学习VLAN原理和子接口概念。
缺点:容易成为网络单点故障,配置稍有复杂,现实意义不大。
实例
SW1
The device is running!
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW1
[SW1]user-interface console 0
[SW1-ui-console0]idle-timeout 0 0
[SW1-ui-console0]q
[SW1]vlan bat 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]int e0/0/1
[SW1-Ethernet0/0/1]port link-type access
[SW1-Ethernet0/0/1]port default vlan 2
[SW1-Ethernet0/0/1]int e0/0/2
[SW1-Ethernet0/0/2]port link-type access
[SW1-Ethernet0/0/2]port default vlan 3
[SW1-Ethernet0/0/2]int g0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/1]q
R1
The device is running!
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]user-interface console 0
[R1-ui-console0]idle-timeout 0 0
[R1-ui-console0]q
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]undo shutdown
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R1-GigabitEthernet0/0/0]int g0/0/0.1
[R1-GigabitEthernet0/0/0.1]vlan-type dot1q 2 default
[R1-GigabitEthernet0/0/0.1]ip add 192.168.2.1 24
[R1-GigabitEthernet0/0/0.1]int g0/0/0.2
[R1-GigabitEthernet0/0/0.2]vlan-type dot1q 3 default
[R1-GigabitEthernet0/0/0.2]ip add 192.168.3.1 24
[R1-GigabitEthernet0/0/0.2]q
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 6 Routes : 6
Destination/Mask Proto Pre Cost Flags NextHop Interface
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.2.0/24 Direct 0 0 D 192.168.2.1 GigabitEthernet
0/0/0.1
192.168.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0.1
192.168.3.0/24 Direct 0 0 D 192.168.3.1 GigabitEthernet
0/0/0.2
192.168.3.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0.2
PC1
Welcome to use PC Simulator!
PC>ping 192.168.3.10
Ping 192.168.3.10: 32 data bytes, Press Ctrl_C to break
From 192.168.3.10: bytes=32 seq=1 ttl=127 time=125 ms
From 192.168.3.10: bytes=32 seq=2 ttl=127 time=78 ms
From 192.168.3.10: bytes=32 seq=3 ttl=127 time=78 ms
From 192.168.3.10: bytes=32 seq=4 ttl=127 time=94 ms
From 192.168.3.10: bytes=32 seq=5 ttl=127 time=94 ms
--- 192.168.3.10 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 78/93/125 ms
PC>ping 192.168.3.1
Ping 192.168.3.1: 32 data bytes, Press Ctrl_C to break
From 192.168.3.1: bytes=32 seq=1 ttl=255 time=47 ms
From 192.168.3.1: bytes=32 seq=2 ttl=255 time=46 ms
From 192.168.3.1: bytes=32 seq=3 ttl=255 time=32 ms
From 192.168.3.1: bytes=32 seq=4 ttl=255 time=47 ms
From 192.168.3.1: bytes=32 seq=5 ttl=255 time=46 ms
--- 192.168.3.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 32/43/47 ms
PC2
Welcome to use PC Simulator!
PC>ping 192.168.2.10
Ping 192.168.2.10: 32 data bytes, Press Ctrl_C to break
From 192.168.2.10: bytes=32 seq=1 ttl=127 time=63 ms
From 192.168.2.10: bytes=32 seq=2 ttl=127 time=93 ms
From 192.168.2.10: bytes=32 seq=3 ttl=127 time=63 ms
From 192.168.2.10: bytes=32 seq=4 ttl=127 time=78 ms
From 192.168.2.10: bytes=32 seq=5 ttl=127 time=78 ms
--- 192.168.2.10 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 63/75/93 ms
PC>ping 192.168.2.1
Ping 192.168.2.1: 32 data bytes, Press Ctrl_C to break
From 192.168.2.1: bytes=32 seq=1 ttl=255 time=31 ms
From 192.168.2.1: bytes=32 seq=2 ttl=255 time=47 ms
From 192.168.2.1: bytes=32 seq=3 ttl=255 time=31 ms
From 192.168.2.1: bytes=32 seq=4 ttl=255 time=47 ms
From 192.168.2.1: bytes=32 seq=5 ttl=255 time=63 ms
--- 192.168.2.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/43/63 ms