Thursday, 19 March 2026

CISCO CLI Create VLAN, Create DHCP, Create Gateway, Create Encapsulation, Create Trunk and Create Access Part 1

 CISCO cli create VLAN, create DHCP, create gateway Create Encapsulation Create trunk and Create access
To create and configure VLANs, DHCP, gateways, and interface types on a Cisco device, you will use the following CLI commands. These steps assume you are in
Global Configuration Mode (configure terminal). 
1. Create a VLAN
To create a VLAN and assign it a name for easier identification: 
bash

Switch(config)# vlan 10
Switch(config-vlan)# name Sales
Switch(config-vlan)# exit

Use code with caution.

    Verification: Use show vlan brief to see all active VLANs. 

2. Create a Gateway (SVI) 
A Switch Virtual Interface (SVI) acts as the default gateway for devices within that VLAN. 
bash

Switch(config)# interface vlan 10
Switch(config-if)# ip address 192.168.10.1 255.255.255.0
Switch(config-if)# no shutdown
Switch(config-if)# exit

Use code with caution.
3. Create a DHCP Pool 
Configure the switch or router to automatically assign IP addresses to clients in a specific VLAN. 
bash

Switch(config)# ip dhcp excluded-address 192.168.10.1 192.168.10.10
Switch(config)# ip dhcp pool SALES_POOL
Switch(dhcp-config)# network 192.168.10.0 255.255.255.0
Switch(dhcp-config)# default-router 192.168.10.1
Switch(dhcp-config)# dns-server 8.8.8.8
Switch(dhcp-config)# exit

Use code with caution.

    Note: Use ip dhcp excluded-address to reserve IPs for static devices like the gateway. 

4. Create Access and Trunk Ports 
Configure physical interfaces to either connect to an end-device (Access) or another network device (Trunk). 

    Access Port (End-device like a PC):
    bash

    Switch(config)# interface fastEthernet 0/1
    Switch(config-if)# switchport mode access
    Switch(config-if)# switchport access vlan 10

    Use code with caution.
    Trunk Port (Connects to another switch or router):
    bash

    Switch(config)# interface fastEthernet 0/24
    Switch(config-if)# switchport mode trunk
    Switch(config-if)# switchport trunk allowed vlan 10,20

    Use code with caution.
     

5. Create Encapsulation (Router-on-a-Stick) 
On a router, you must define the encapsulation type (usually IEEE 802.1Q) on a sub-interface to route between VLANs. 
bash

Router(config)# interface gigabitEthernet 0/0.10
Router(config-subif)# encapsulation dot1q 10
Router(config-subif)# ip address 192.168.10.1 255.255.255.0

Use code with caution.
Do you need to configure inter-VLAN routing specifically for a Layer 3 switch or a Router-on-a-Stick setup? 

No comments:

Post a Comment