Hello and welcome to the #Cisco section. In this post we will cover how to statically add an IP address on a Cisco device. We will look at how you can assign an IP address on a physical interface, or how you can assign an IP address to a VLAN.
If you have GNS3 and the Cisco VIRL images installed we can easily lab this together, if you do not have GNS3 installed we have an entire section dedicated to how to install the software in order to do labs together which I highly recommend you use to your own benefit.
If you're here configuring a Cisco device and you're looking for guidance then you're also welcome here! So let's get started and look at how we can statically assign an IP address to a Cisco device!
How to add an IP to a physical interface
Firstly let's look at the below topology and what our objective is. We would like to configure the 192.168.99.0/24 subnet between our host and our router on Gi0/0.
So let's head into the console window of the router and begin the configuration process. If you are configuring a router please always ensure you are in Enabled mode or the more correct term Privileged EXEC mode by typing "en" or "enabled" and typing the enable mode password. You should have a "#" symbol next to your router identity if you are in Proviledged EXEC mode.
Please type in "config t" or "configuration terminal" and hit enter to enter configuration mode, from here we will go into the interface configuration mode by typing in the interface we wish to configure. In our topology it is Gi0/0. Please type "int Gi0/0" or "Interface GigabitEthernet0/0" and hit enter. This will bring you into the Interface Configuration mode.
NB: Remember that you can get out of configuration mode by pressing "ctrl + z" on your keyboard. It is also wise to save any running configuration by using the "wr" or "copy run start" command after making changes.
We are now able to assign an IP address to the interface by using the "ip address" command. We will assign an IP within the 192.168.99.0/24 subnet to this interface as per our topology, however this could be any IP of your choosing on your IP address planning. You will notice now if we look at the interfaces when doing a "show ip int br" or "show ip interface brief" the GigabitEthernet0/0 now has an IP address that we specified.
We've already assigned the 192.168.99.2/24 address to the host and we are able to ping the host from the Cisco router on the IP address. If we also do a "show arp" it shows us that we are learning a mac-address on this IP of the host.
How to add an IP to a VLAN interface
Let us assume that our host was not directly connecting to the Cisco router on Gi0/0, however was connecting via a Cisco switch. What if we wanted to give this switch a management IP on a VLAN? How would be go about doing that? Well... As before let's first look at the topology that we want to create.
As with the Cisco router let's get into our Cisco switch's console window and configure an IP address via the CLI. Remember to first get into Enable mode or Privileged EXEC mode by typing in "en" or "enabled" and typing in the enable mode password.
Now let's get back into configuration mode by typing "Conf T" or "Config Terminal". Once we're in the configuration mode let us enter the interface configuration mode. However, this time instead of going into a physical interface we will go into a VLAN. Let's use the default VLAN which is VLAN1 (Note all ports run on VLAN1 by default). So let's type "int VLan1" or "interface VLAN1"
As we're in the interface configuration mode we can do the same as before by using the "ip address" command. So let's add the 192.168.99.3/24 address to the VLAN by typing "ip address 192.168.99.3 255.255.255.0" and hitting enter. Also note that you may need to unshut your VLAN before the IP will come up.
Go ahead and ping your router and host from the VLAN IP, you will see that you are now getting a response. As before if we look at our arp entries we will see that we have IP addresses that resolve to mac-addresses as well. So we can confirm we have L3 and L2 communication.
That's a wrap
We have successfully gone through how to add an IP address on a Cisco device. You are now able to configure an IP address on both a physical interface and a VLAN. I hope that this has been informative and that you have learned something new.