1 How to Implement Inter-VLAN Mutual Access Through Router-on-a-Stick on Sub-interfaces
Implementing inter-VLAN mutual access using
sub-interfaces
In a Layer 2 switching environment, a VLAN is a
broadcast domain. Typically, different VLANs are different logical subnets,
which are isolated from each other. Mutual access between VLANs is not allowed,
so packets in one VLAN cannot be broadcast to another. On live networks,
however, VLANs need to communicate with each other. For example, if different
departments of a company are deployed in separate VLANs, a Layer 2 switch
cannot implement data exchange between these departments. In this case, a Layer
3 device needs to be used. The simplest method is to use a router, as shown in
the following figure:
In the
above figure, GE0/0/1 and GE0/0/23 on the switch are added to VLAN 10; GE0/0/2
and GE0/0/24 on the switch are added to VLAN 20; GE0/0/1 on the router is used
as the gateway of users in VLAN 10; GE0/0/0 on the router is used as the
gateway of users in VLAN 20. In this way, the routing function of the router is
leveraged to implement inter-VLAN mutual access. This method may seem feasible.
However, one VLAN occupies a router interface. This results in heavy burdens of
the router if the intranet has many VLANs. A better method for implementing
inter-VLAN mutual access is to use one physical interface of the router with
logical sub-interfaces configured. This method is called router-on-a-stick.
In the
above figure, only one link is used between the switch and the router. This
link needs to be configured as a trunk link because it needs to carry data from
multiple VLANs. That is, Dot1q encapsulation needs to be configured on the
switch. The router only needs to provide one physical interface for connection
with the switch. On this physical interface, multiple sub-interfaces can be
created to identify data from different VLANs. For example, the sub-interface
GE0/0/0.10 is created to identify data from VLAN 10 and the sub-interface
GE0/0/0.20 is created to identify data from VLAN 20. In this way, the router
can exchange data from multiple VLANs using only one physical interface. The
configuration details are as follows: