Static host records on Cisco devices map hostnames to IP addresses locally, eliminating the need for a DNS server to resolve network equipment names. This technique is especially useful in lab and small network environments where a full DNS infrastructure is not available.
Host Records on Network Devices
One thing that can be really handy on these devices is using host records.
Here I am on switch one, and what I want to do is ping R1. So I'm going to ping R1, which is 10.24.0.2. So ping 10.24.0.2, we hit enter, and it's no problem at all.
But let's say I don't want to type in IP addresses — maybe I want to use names instead. R1 is already set up with the host name R1, so let's see what happens when we ping R1. I hit there, and what it's doing is it's trying to translate R1 and find what the IP address for R1 is, and it's going to become unsuccessful with this, because there's nothing to look up. So this is what I want to solve for: I want to be able to ping R1. You can't just set the host name on one of them and be able to ping it. Instead, what we have to do is set up a host record on this machine.
The first thing I'm going to do is get into the global configuration mode, so conf t to get into that.
One way that I can solve this problem is to reference a domain name server, so a DNS server. I'm going to do ip name-server and then the IP address of whatever server that I'm going to use for this. Now, in this case right here, even if we had a name server set up, we wouldn't necessarily have all of our equipment set up on that name server, so in that case this method would not actually work.
So I'm going to show you a different way to do that. I can type in ip host — that's the command — and then R1 is the name, and then I can type in the IP address, 10.24.0.2, and hit enter. Now I'm going to do ping R1 and see what happens here. It still goes through and tries to do the lookup process here, but as soon as it does that, it's going to ping 10.24.0.2, because now we've got a record for that, and we can see that that was successful.
If I want to take this away, then all I have to do is just put a no in front of it, and then that removes it. And if I want to test this out now that it's removed, I just ping R1 again — oops, need a do in front of that — and then we can see that this is going to fail again.
There is an IP version 6 of this command also, so that you just add a v6 to it and everything else is the same. Well, of course, you're using the IP version 6 address rather than the IP version 4 address. So I'm going to type in that address — and I forgot the name, so we'll put R1 here — and now let's do ping R1 and see what happens here. It goes immediately to the ping this time, and so now it is successful.
One other command that we can use, because this gets really annoying if we mess up and type something wrong and have to wait for this: one thing that we could do also is we could use the command no ip domain-lookup. Let's enter that in, and let's ping something we haven't created a record for. We haven't created a record for R3, so we hit ping R3 — and do we need to put a do in front of that — and we can see that it's not even going to try.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →