Configuring an IP address on a Cisco Device
Configure a static IP address on an interface
To configure a static IP address on an interface, you need to enter interface configuration mode and then use the ip address command to assign the IP address and subnet mask. Here's how to do it:
Router> enable
Router# configure terminal
Router(config)# interface GigabitEthernet0/1
Router(config-if)# ip address 192.168.1.1 255.255.255.0
Router(config-if)# no shutdown
Router(config-if)# exit
Router(config)# exitConfigure DHCP on an interface
If you want the interface to obtain its IP address automatically via DHCP, use the ip address dhcp command:
Router> enable
Router# configure terminal
Router(config)# interface GigabitEthernet0/1
Router(config-if)# ip address dhcp
Router(config-if)# no shutdown
Router(config-if)# exit
Router(config)# exitVerify the IP address configuration
To verify that the IP address has been configured correctly, you can use several show commands:
Router# show ip interface brief
Router# show interface GigabitEthernet0/1
Router# show running-config interface GigabitEthernet0/1The show ip interface brief command provides a quick overview of all interfaces and their IP addresses. The show interface command gives detailed information about a specific interface, including its IP configuration. The show running-config interface command displays the current configuration for a specific interface.
Video Tutorial
For a visual demonstration of configuring IP addresses on Cisco devices, watch this video tutorial:
Important Notes
- Always remember to use the
no shutdowncommand to bring the interface up after configuring the IP address - The subnet mask can also be specified using CIDR notation, for example:
ip address 192.168.1.1 255.255.255.0is equivalent toip address 192.168.1.1/24 - If you're configuring a switch interface, you would typically configure the management VLAN interface (usually
interface vlan 1) rather than a physical port - Make sure to save your configuration using
copy running-config startup-configto preserve your settings after a reboot