Configure An IP Address On A Switch
Configure An IP Address On A Switch
Configure An IP Address On A Switch
By default, Cisco switches forward Ethernet frames without any configuration. This
means that you can buy a Cisco switch, plug in the right cables to connect various
devices to the switch, power it on, and the switch will work properly.
However, to perform switch management over the network or use protocols such as
SNMP, the switch will need to have an IP address. The IP address is configured under
a logical interface, known as the management domain or VLAN. Usually, the default
VLAN 1 acts like the switch’s own NIC for connecting into a LAN to send IP packets.
Here are the steps to configure an IP address under VLAN 1:
1. enter the VLAN 1 configuration mode with the interface vlan 1 global configuration
command.
2. assign an IP address with the ip address IP_ADDRESS SUBNET_MASK interface
subcommand.
3. enable the VLAN 1 interface with the no shutdown interface subcommand.
4. (Optional) use the ip default-gateway IP_ADDRESS global configuration command to
configure the default gateway.
5. (Optional) Add the ip name-server IP_ADDRESS global configuration command to
configure the DNS server.
We have a simple network of a host and a switch. We can assign the switch with an IP
address to enable IP communication between the two devices:
SW1(config)#int vlan 1
SW1(config-if)#
SW1(config-if)#
SW1(config-if)#no shutdown
SW1(config-if)#
To verify the IP address set on a switch, we can use the show int vlan 1 command:
....
We can verify that the host can reach the switch using its IP address by pinging it from
Host A:
C:\>ping 10.0.0.2
...
The ARP table on a Cisco router
Just like regular hosts, if a Cisco router wants to exchange frames with a host in the
same subnet, it needs to know its MAC address. The IP-to-MAC address mapping are
kept in the router’s ARP table. Consider the following example:
R1#show ip arp
The ARP table contains two entries for R1’s own two interfaces with the IP address of
10.0.0.1 and 172.16.0.1. The – in the age column indicates that the entry will never be
timed out.
The ARP table also lists the MAC addresses of the two connected hosts. Consider the
entry for Host A:
Here are the steps R1 needs to take before forwarding frames to Host A:
1. R1 wants to communicate with Host A. R1 checks its routing table. The subnet on which
Host A resides is a directly connected subnet.
2. R1 checks its ARP table to find out whether the Host A’s MAC address is known. If it is
not, R1 will send an ARP request to the broadcast MAC address of FF:FF:FF:FF:FF:FF.
3. Host A receives the frame and sends its MAC address to R1 (ARP reply). The host also
updates its own ARP table with the MAC address of the Gigabit0/0 interface on R1.
4. R1 receives the reply and updates the ARP table with the MAC address of Host A.
5. Since both hosts now know each other MAC addresses, the communication can occur.
ARP request packets are sent to the broadcast addresses (FF:FF:FF:FF:FF:FF for the
Ethernet broadcasts and 255.255.255.255 for the IP broadcast).
All operating systems maintain ARP caches that are checked before sending an ARP
request message. Each time a host needs to send a packet to another host on the LAN,
it first checks its ARP cache for the correct IP address and matching MAC address. The
addresses will stay in the cache for a couple of minutes. You can display ARP entries in
Windows by using the arp -a command:
The no ip domain-lookup Command
By default, any single word entered on an IOS device that is not recognized as a valid
command is treated as a hostname to which you want to telnet. The device will try to
translate that word to an IP address in a process that can last about a minute.
R1#writte
In the output above you can see that I’ve mistyped the command write. The router
entered the DNS resolution process which lasted about a minute. This can be annoying
and this is why this feature is often turned off, especially in the lab environments.
If you don’t need to have a DNS server configured for your router, you can use the no ip
domain-lookup command to disable the DNS translation process:
R1(config)#no ip domain-lookup
Now, if I mistype a command, the router will not perform a DNS resolution process:
R1#writte
Translating "writte"
R1#
How to Configure a Cisco Router as a DNS
Server?
Domain Name System or DNS is considered as the phonebook of the Internet. DNS
servers resolve domain names to IP addresses. Google Public DNS (8.8.8.8 and
8.8.4.4) is an example of free DNS services and can replace your ISP’s default DNS
server addresses.
1. Using the sample network topology above, let’s configure the IP address first on each
device.
DNS(config)#interface GigabitEthernet0/0
#ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:00:00:06:00
collisions:0 txqueuelen:1000
3. Configure the Domain Name System server with the hostname of your local hosts. In
this case, when any other PC wants to ping the ‘dnstest.lab’ server, the router will
resolve its domain name to the appropriate IP address.
DNS(config)#ip host dnstest.lab 172.16.0.2
DNS#ping dnstest.lab
!!!!!
C:\Users\PC1>ping dnstest.lab
1. (Optional) If you’ve previously disabled DNS lookups on your device, re-enable it with
the ip domain-lookup command.
2. Specify the IP address of the DNS server using the ip name-server command. It is
possible to specify up to six DNS servers.
3. (Optional) Specify the domain name to append to the hostname you type in by using
the ip domain-name command.
In the output above you can see that I’ve specified the IP address of my DNS server
(192.168.0.100). Let’s say that the DNS server contains a record for a server
called fileshare. I can try to ping that host using its hostname to verify that the name
resolution process is indeed working:
Floor1#ping fileshare
Translating "fileshare"...domain server (192.168.0.100)
.!!!!
As you can see from the output above, the hostname fileshare was translated to the IP
address of 192.168.0.110.
The mappings can be defined using the global configuration command ip host
HOSTNAME IP_ADDRESS:
In the output above we’ve defined the IP address of 192.168.0.100 for the
hostname HQ_SERVER. To display the hostname-to-address mappings, the show
hosts command is used:
Floor1#show hosts
Floor1#ping HQ_SERVER
!!!!!
You can see that HQ_SERVER responded to the ping request, which means that the
name resolution was successful.
NOTE
The drawback of this method of name resolution is that we need to create static hostname-to-
address mappings on each device in order to be able to resolve hostnames. If possible, use DNS
instead.
Before the DNS is being implemented, the computer can use a domain name by using a
host file. The host file contains the hostname and maps it to a specific IP address.
Whenever the computer wants to visit a website on the internet, it will check first on the
host file and map it to the IP address of the website. What if the hostname of the
website or its IP address is not registered on the host file? The computer will not be able
to connect to the website.
Frequently updating the host file is not a convenient and efficient way as the internet is
continuously growing. To solve the issue, a DNS Server (Name Server) was created.
The DNS servers are being the root servers for its domain and contain all the DNS
records for the specific domain like TLD. Top-Level Domain (TLD) is a domain that
contains a root (.) and ends name like .net, .com, or .org. On the other hand, the Fully
Qualified Domain Name (FQDN) contains a hostname, domain name, and TLD. When
accessing www.google.com, “www” is the hostname, “google” is the domain name, and
“.com” is the TLD.
NOTE
A hostname represents a network used to deliver a user to a specific address, while a domain
name is a site that the user is accessing.
It can inspect incoming packets in the network layer, support routing protocols, and
even make routing decisions based on the source and destination IP addresses. With
both its Layer 2 and Layer 3 capabilities, this device is popularly known also as a
Multilayer Switch. Just be mindful that Layer 3 switches do not have WAN ports which
should be considered while designing your network.
How do Layer 3 Switches function in the Network?
Layer 2 switch dynamically routes traffic between its physical interfaces according to the
MAC addresses of the connected devices, wherein Layer 3 switches use this feature to
manage traffic in a LAN. A Layer 2 switch functions well in low to medium traffic in its
VLANs, but these switches have their limitations once traffic increases.
The Layer 3 switch was conceived to augment this limitation by developing equipment
that has routing capabilities within the same chassis. The hardware is where the main
difference lies. Layer 3 switches have a mix of traditional switches and routers, except
for the fact that the router’s software logic is replaced by integrated circuit hardware to
improve its performance further.
Layer 3 switches can perform on the OSI model’s Layer 2 and Layer 3. The Layer 3
switching functionality can take either of two forms:
Cut-through switches – will only look into the first packet of a series of packets to determine its
logical Layer 3 destination IP address and then shift the remainder of the packets in the series
using the MAC address leading to higher data throughput rates.
Packet-by-Packet Layer 3 (PPL3) switches – will look into every packet to determine its
logical Layer 3 destination IP address. A PPL3 switch basically functions as a high-speed router
with the routing functionality built into its hardware instead of software. Similar to routers, aside
from forwarding packets to their destination, PPL3 switches perform other functions that a
standard router accomplishes, such as using the packet’s checksum to verify its integrity,
updating the packet’s Time to Live (TTL) information after each hop, and processing any
optional information in the packet’s header.
We have a network of three hosts and a router. Note that each computer is on a
different network. Host A wants to communicate with Host B and sends the packet with
the Host B’s IP address (10.0.0.20) to the router. The router receives the packet,
compares the packet’s destination IP address to the entries in its routing table and finds
a match. It then sends the packet out the interface associated with the network
10.0.0.0/24. Only Host B will receive and process the packet. In fact, Host C will not
even be aware that the communication took place.