Most devices on the network have IP addresses. IP addresses look like a single address, but actually include the network (subnet) and the host.
The network portion is used when a packet needs to be sent to another network. The host portion is used for delivery to the end device.
An IP address comes with a subnet mask. The mask is a series of binary 1’s, followed by some 0’s. When we align the mask with the IP address, the 1’s show the network portion, and the 0’s show the host portion.
The size of the network can affect the maximum number of hosts in that network. That is, the more 1’s in a subnet mask, the bigger the network. This means less 0’s, which means fewer maximum hosts.
The number of 1’s in a subnet mask can change. This is called Variable Length Subnet Mask, or VLSM.
The subnet mask can be displayed in dotted decimal notation (which looks like an IP address), or in CIDR notation.
The very first host IP in a subnet is the network address. The host bits are all zero. The very last host IP is the broadcast IP, where the host bits are all ones.
Routers and Layer-3 Switches
Routers move packets from one subnet to another. Some switches can work at layer-3, which gives them the same functionality.
A host knows how to find the nearest router, as it’s configured with a default gateway. This is the IP address of the router.
When forwarding a packet to the router, the packet will include the MAC address of the router as the destination. The IP address will still be the end device. The MAC address is found using a protocol called ARP.
Layer-3 switches are particularly useful when forwarding packets between VLANs in the LAN. To do this, they are configured with SVIs, or Switched Virtual Interfaces. This is sometimes called Integrated Routing and Bridging (IRB), as the interface binds layer-3 (an IP address) to layer-2 (a VLAN ID).
Physical interfaces can be configured as layer 2 (switchport) or layer 3 (no switchport). Layer-2 interfaces are configured with VLANs, while layer-3 interfaces are configured with IP addresses.
The Routing Table
Routers have a routing table. This table lists all the networks that the router knows about, and ‘signposts’ pointing out how to get there.
When the router has an interface in a network, that network shows in the routing table as connected. The IP of the interface shows in the routing table as local.
The ‘signposts’ pointing out how to reach the destination network are actually ‘next-hop IP addresses’. These are IP addresses of the next router that a packet needs to be forwarded to on its journey.
The Gateway of Last Resort is Cisco’s term for the router’s default gateway. This is where all packets are sent when there is no better alternative.
The key to understanding the routing table is Longest Prefix Match (LPM). That is, if a packet fits within a few routes in the table, the one with the longest subnet mask is chosen.
A Prefix is another name for the network portion of the IP address.
|ip address <ip> <mask>
|Set an IP address on an interface
|Shutdown an interface
|Enable an interface (remove the shutdown)
|show ip interface brief
|Show a list of interfaces and IP addresses
|Create a new VLAN
|interface vlan <id>
|Create a new SVI (Switched Virtual Interface)
|Enable Layer-3 mode on a switch
|Change an interface to layer-2 mode
|Change an interface to layer-3 mode
|show ip route
|Show the routing table
|ip route <network> <mask> <next-hop>
|Add a static route
|show run all
|Show running-config, including hidden config