DHCP on Switch Over VLAN
To configure DHCP on a VLAN in a Cisco switch, you need to create a DHCP pool, define the DHCP options, and assign the VLAN interface to the DHCP pool. Here are the steps to configure DHCP on a VLAN in a Cisco switch:
Assumptions:
- You have already created a VLAN on the switch.
- You have a DHCP server configured and reachable from the switch.
1. Access Configuration Mode:
- Description: Access the switch's command-line interface (CLI) and enter configuration mode.
bashSwitch> enable
Switch# configure terminal
2. Create a DHCP Pool:
- Description: Create a DHCP pool for the VLAN you want to configure. Replace
vlan_idwith the actual VLAN ID and specify the IP address range for the VLAN.
bashSwitch(config)# ip dhcp pool vlan_id
Switch(dhcp-config)# network network_address subnet_mask
- Example:
bashSwitch(config)# ip dhcp pool 10
Switch(dhcp-config)# network 192.168.10.0 255.255.255.0
3. Define DHCP Options (Optional):
- Description: You can define optional DHCP options like DNS servers, default gateway, and domain name if needed.
bashSwitch(dhcp-config)# default-router default_gateway
Switch(dhcp-config)# dns-server dns_server_ip
Switch(dhcp-config)# domain-name example.com
- Example:
bashSwitch(dhcp-config)# default-router 192.168.10.1
Switch(dhcp-config)# dns-server 8.8.8.8
Switch(dhcp-config)# domain-name example.com
4. Assign the VLAN Interface to the DHCP Pool:
- Description: Assign the VLAN interface to the DHCP pool you created.
bashSwitch(config)# interface vlan vlan_id
Switch(config-if)# ip dhcp server pool vlan_id
- Example:
bashSwitch(config)# interface vlan 10
Switch(config-if)# ip dhcp server pool 10
5. Verify the DHCP Configuration:
- Description: To verify the DHCP configuration on the switch, you can use the following command:
bashSwitch# show running-config | section dhcp
- Description: This command displays the DHCP configuration section of the running configuration, allowing you to review your settings.
6. Save the Configuration:
- Description: After configuring DHCP, be sure to save the configuration to the startup configuration to ensure it persists after a reboot.
bashSwitch# write memory
With these steps, you have configured DHCP on a VLAN in your Cisco switch.
Comments
Post a Comment