Router On A Switch Setup
Setup topo
Port Ethernet0 is in access mode, with VLAN ID 1,
connected to VLAN1-PC-1 on port ens4
Port Ethernet1 is in access mode, with VLAN ID 1,
connected to VLAN1-PC-2 on port ens4
Port Ethernet2 is in access mode, with VLAN ID 2,
connected to VLAN2-PC-1 on port ens4
Port Ethernet3 is in access mode, with VLAN ID 2,
connected to VLAN2-PC-2 on port ens4
Port Ethernet4 is in access mode, with VLAN ID 3,
connected to VLAN3-PC-1 on port ens4
Port Ethernet5 is in access mode, with VLAN ID 3,
connected to VLAN3-PC-2 on port ens4
Port Ethernet6 is in access mode, with VLAN ID 4,
connected to VLAN4-PC-1 on port ens4
Port Ethernet7 is in dot1q mode, with native VLAN 1,
connected to R1 on port FastEthernet0/0
For each guest, we setup the IP following this format:
VLAN1-PC-1: 192.168.1.2
VLAN1-PC-2: 192.168.1.3
...
VLAN3-PC-1: 192.168.3.2
VLAN3-PC-2: 192.168.3.3
...
Each VLAN will have a default router for that. For example, VLAN1 will be default routed to 192.168.1.1
and VLAN3 will be default routed to 192.168.3.1
.
Setup the router
We can do a show ip int brief
to show the current configuration default.
Since we only connect FastEthernet0/0
. We are gonna enable this port:
> en
> config terminal
> int FastEthernet0/0
> no shutdown
After this this port should be enable
Next, we need to create Sub Interface:
> en
> config terminal
# Create for vlan id 1
> int FastEthernet0/0.1 # .1 because vlan id 1
> encap dot1q 1 # same as vlan id
> ip address 192.168.1.1 255.255.255.0
> no shutdown
...
# create for vlan id 3
> int FastEthernet0/0.3
> encap dot1q 3
> ip address 192.168.1.3 255.255.255.0
> no shutdown
...
As a result, now we can ping cross vlan from 192.168.1.2 -> 192.168.3.2
.