Dot1q三层交换配置相关知识总结(单臂路由router-on-a-stick)
Dot1q三层交换相关知识总结
1.什么是dot1q?什么是IEEE 802.1?什么是IEEE 802.1q?
dot1q 就是802.1q,dot就是点的意思,简写为dot1q;
IEEE 802.1 是一组协议的集合,这个集合里面有很多子协议,如:IEEE 802.1a定义局域网体系结构;IEEE 802.1s定义多生成树协议;IEEE 802.1w定义快速生成树协议;IEEE 802.1x定义局域网安全认证;
IEEE 802.1q 是“Virtual Bridged Local Area Networks”(虚拟桥接局域网,简称“虚拟局域网”)协议,主要规定了VLAN的实现方法。是一种提供VLAN标识和服务质量(QoS)级别的IEEE标准。
2.何谓三层交换,为什么这么做?
何为三层交换?
当二层交换机经过VLAN划分后,彼此如何连通?可通过三层路由器作为各个VLAN的网关,经由三层路由器里的VLAN协议(dot1q)和ARP协议,处理各VLAN段发过来的包,并转发至正确的vlan段。因为是从二层交换机发过来的帧,处理完后又发回给二层交换机。从而借由加入VLAN标签可使多个VLAN透过一个链接多路复用。即用一根网线连接路由器和交换机,两者联合处理二层vlan间的数据帧的数据交换。
为了完成vlan间数据交换,用到三层设备路由器,实际上是路由器跑二层协议。叫三层交换很准确,叫单臂路由有点牵强(有点凑合的感觉)
[Router] interface GigabitEthernet0/0/1.2 //交换机与路由器连接的那个网口,就进入那个网口,并设置子网口
[Router-GigabitEthernet0/0/1.2] dot1q termination vid 20 //在0/0/1.2子接口上,启用VLAN dot1q协议,并允许vlan20相关的帧通过
[Router-GigabitEthernet0/0/1.2] arp broadcast enable //启用ARP广播协议
[Router-GigabitEthernet0/0/1.2] ip address 192.168.20.254 24 //给0/0/1.2子接口配置IP地址,作为vlan20 的网关地址
注:从以上可以看出,其实就是在三层的路由器上,跑二层的交换机的应用协议。所以叫三层交换恰如其分。这些设备基本结构与电脑类似,只是各自侧重功能不同,所有都能跑不奇怪!
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe77:61f2
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.10.1
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.10.254
Physical address..................: 54-89-98-77-61-F2
DNS server........................:
PC>ping 192.168.20.2
Ping 192.168.20.2: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.20.2: bytes=32 seq=2 ttl=127 time=78 ms
From 192.168.20.2: bytes=32 seq=3 ttl=127 time=93 ms
From 192.168.20.2: bytes=32 seq=4 ttl=127 time=79 ms
From 192.168.20.2: bytes=32 seq=5 ttl=127 time=78 ms
--- 192.168.20.2 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/82/93 ms
外网找到的参考文章
VLAN Routing with Router 802.1Q Trunks
Almost all enterprise networks use VLANs. To route IP packets in and out of those VLANs, some devices (either routers or Layer 3 switches) need to have an IP address in each subnet and have a connected route to each of those subnets. Then the IP addresses on those routers or Layer 3 switches can serve as the default gateways in those subnets.
This chapter breaks down the LAN routing options into four categories:
-
Use a router, with one router LAN interface and cable connected to the switch for each and every VLAN (typically not used)
-
Use a router, with a VLAN trunk connecting to a LAN switch (known as router-on-a-stick, or ROAS)
-
Use a Layer 3 switch with switched virtual interfaces (SVI)
-
Use a Layer 3 switch with routed interfaces (which may or may not be Layer 3 EtherChannels)
Of the items in the list, the first option works, but to be practical, it requires far too many interfaces. It is mentioned here only to make the list complete.
As for the other three options, this chapter discusses each in turn as the main focus of one of the three major sections in this chapter. Each feature is used in real networks today, with the choice to use one or the other driven by the design and needs for a particular part of the network. Figure 17-1 shows cases in which these options could be used.
FIGURE 17-1 Layer 3 Switching at the Central Site
Figure 17-1 shows two switches, labeled A and B, which could act as Layer 3 switches—both with SVIs and routed interfaces. The figure shows a central site campus LAN on the left, with 12 VLANs. Switches A and B act as Layer 3 switches, combining the functions of a router and a switch, routing between all 12 subnets/VLANs, as well as routing to/from the Core router. Those Layer 3 switches could use SVIs, routed interfaces, or both.
Figure 17-1 also shows a classic case for using a router with a VLAN trunk. Sites like the remote sites on the right side of the figure may have a WAN-connected router and a LAN switch. These sites might use ROAS to take advantage of the router’s ability to route over an 802.1Q trunk.
Note that Figure 17-1 just shows an example. The engineer could use Layer 3 switching at each site or routers with VLAN trunking at each site.