Configuring Cisco devices involves separate steps on the
switch for VLANs and port modes, and on the router for inter-VLAN routing (encapsulation) and DHCP services.
Switch Configuration (VLANs, Access, Trunk)
These commands are executed on the Cisco switch to create VLANs and configure the ports.
Enter global configuration mode:
cisco
enable
configure terminal
Create VLANs:
cisco
vlan 10
name DATA_VLAN
vlan 20
name VOICE_VLAN
exit
Configure Access Ports (for end devices like PCs/phones):
cisco
interface FastEthernet0/1 (or specific interface name)
switchport mode access
switchport access vlan 10
exit
Configure Trunk Ports (for links to other switches or routers):
cisco
interface GigabitEthernet0/1 (or specific interface name)
switchport mode trunk
switchport trunk encapsulation dot1q (Needed on some older or multi-layer switches)
switchport trunk allowed vlan 10,20 (Optional: limits which VLANs are allowed)
exit
Router Configuration (Encapsulation, Gateway, DHCP)
These commands are executed on the router to enable inter-VLAN routing and provide DHCP services.
Enter global configuration mode:
cisco
enable
configure terminal
Configure Encapsulation and Gateway (Router-on-a-stick):
Create subinterfaces on the router's physical interface (e.g., GigabitEthernet0/0) for each VLAN. Each subinterface will serve as the default gateway for its respective VLAN.
For VLAN 10:
cisco
interface GigabitEthernet0/0.10
encapsulation dot1Q 10
ip address 192.168.10.1 255.255.255.0 (This is the **default gateway** for VLAN 10 clients)
no shutdown
exit
For VLAN 20:
cisco
interface GigabitEthernet0/0.20
encapsulation dot1Q 20
ip address 192.168.20.1 255.255.255.0 (This is the **default gateway** for VLAN 20 clients)
no shutdown
exit
Configure DHCP Server:
Create a separate DHCP pool for each VLAN's subnet, specifying the default router and DNS server.
Exclude addresses (optional, but recommended for static IPs like the gateway):
cisco
ip dhcp excluded-address 192.168.10.1 192.168.10.5
ip dhcp excluded-address 192.168.20.1 192.168.20.5
Create pool for VLAN 10:
cisco
ip dhcp pool VLAN10_POOL
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1
dns-server 8.8.8.8 4.4.4.4 (Example public DNS servers)
exit
Create pool for VLAN 20:
cisco
ip dhcp pool VLAN20_POOL
network 192.168.20.0 255.255.255.0
default-router 192.168.20.1
dns-server 8.8.8.8 4.4.4.4
exit
Save the configuration on both devices:
cisco
copy running-config startup-config
Thursday, 19 March 2026
CISCO CLI Create VLAN, Create DHCP, Create Gateway, Create Encapsulation, Create Trunk and Create Access Part 2
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment