VMware ESXi and vSphere Cluster Management

What Is a Router? Routing Between IP Networks

Learn what a router does, how it forwards IP packets between networks, how default gateways and routing tables work, and how routers differ from switches and bridges.

What Is a Router?

A router is a Layer 3 network device that forwards IP packets between separate networks. It receives traffic through one network interface, examines the destination IP address, and sends the packet through another interface toward the destination network.

Routing is necessary when a device communicates beyond its local IP subnet. Devices on the same subnet can usually exchange traffic directly at Layer 2. Traffic for a different subnet must be sent to a router, normally through the host's default gateway.

Important terms

  • IP packet: A Layer 3 unit of data containing source and destination IP addresses.
  • Destination IP address: The Layer 3 address a router uses to decide where a packet should go.
  • Subnet: A logical IP network identified by a network prefix and prefix length or subnet mask.
  • Routing: Selecting a path and forwarding packets toward another network.

Routers and the OSI Model

A router primarily operates at Layer 3, the network layer, of the OSI model. Its central forwarding decision uses the destination IP address in an IP packet.

Layer 2 devices make a different kind of decision. A switch or bridge forwards Ethernet frames using MAC addresses. A router forwards IP packets between IP networks using routing information.

Forwarding typeUnit of dataMain address usedTypical purpose
Layer 2 switchingEthernet frameMAC addressDeliver traffic within a LAN or VLAN
Layer 3 routingIP packetDestination IP addressDeliver traffic between different IP networks

Routers still use Layer 2 information on each physical network. The distinction is that the router makes the path decision at Layer 3, then uses the appropriate Layer 2 method to deliver the packet on the next link.

Router Interfaces and Connected Networks

A router normally connects to two or more networks. Each router interface is assigned an IP address and belongs to a particular IP network or subnet. The router therefore acts as a boundary between those networks.

For example, one interface might connect to 192.168.1.0/24, while another connects to 10.0.0.0/24. Hosts in the first subnet cannot treat hosts in the second subnet as local. They send remote traffic to the router interface in their own subnet.

Each interface is also a separate physical or logical network segment. Where the physical technology supports it, an interface can operate in full-duplex mode, allowing it to send and receive simultaneously.

How a Router Forwards a Packet

  1. A sending host determines whether the destination IP address is local or remote by comparing it with its own address and subnet mask.
  2. If the destination is remote, the host sends the traffic to its default gateway, which is a router interface in the host's local subnet.
  3. The router receives the Layer 2 frame and removes the incoming frame encapsulation.
  4. The router examines the destination IP address in the IP packet.
  5. The router searches its routing table for the best matching destination network.
  6. The selected route identifies a next hop, an outgoing interface, or both.
  7. The router forwards the IP packet through the selected outgoing interface inside a new Layer 2 frame.

The destination IP address normally remains unchanged as the packet crosses routed networks. The Layer 2 addressing changes at each hop because each link has its own local frame delivery. The source and destination MAC addresses in the incoming frame are replaced with appropriate addresses for the next network.

Default gateway

The default gateway is the local router address a host uses to reach destinations outside its own subnet. A host sends traffic directly to devices on its local subnet, but sends remote-destination traffic to the gateway.

The gateway address must be in the host's local subnet. For example, a host configured as 192.168.1.10/24 can use 192.168.1.1 as its gateway because both addresses belong to 192.168.1.0/24. A gateway such as 10.0.0.1 would not be a valid local gateway for that host.

Routing Tables

A routing table is the collection of reachability entries a router uses to select paths. A route connects a destination network prefix with a next hop or outgoing interface.

A directly connected route is known because the router has an active interface in that network. Other routes may be manually configured, such as static routes, or learned through a dynamic routing protocol.

Destination networkPrefix length or maskRoute typeNext hopExit interface
192.168.1.0/24Directly connectedNot requiredInterface connected to the 192.168.1.0 network
10.0.0.0/24Directly connectedNot requiredInterface connected to the 10.0.0.0 network
172.16.1.0/24Directly connectedNot requiredInterface connected to the 172.16.1.0 network
0.0.0.0/0Default routeUpstream provider routerInterface toward the provider

When several routes match a destination, the router applies longest-prefix match. This means it prefers the most specific matching prefix. A route for 10.0.0.0/24 is preferred over a less specific route such as 10.0.0.0/16 when both match the destination.

  • Destination network: The range of addresses the route describes.
  • Prefix length or subnet mask: Defines how specific the destination network is.
  • Next hop: The next router or destination device to which the packet is sent.
  • Outgoing interface: The interface selected to transmit the packet toward its next destination.

Example: Traffic Across Three Networks

Consider three hosts connected to three different interfaces on one router:

DeviceIP addressDefault gatewayNetwork
Host A192.168.1.10/24192.168.1.1192.168.1.0/24
Router interface toward A192.168.1.1/24Not applicable192.168.1.0/24
Host B10.0.0.20/2410.0.0.110.0.0.0/24
Router interface toward B10.0.0.1/24Not applicable10.0.0.0/24
Host C172.16.1.30/24172.16.1.1172.16.1.0/24
Router interface toward C172.16.1.1/24Not applicable172.16.1.0/24

Suppose Host A sends traffic to Host B at 10.0.0.20.

StepDeviceDestination IP addressLayer 2 destination at that hopAction
1Host A10.0.0.20MAC address of gateway 192.168.1.1Host A recognizes that Host B is outside its local subnet and sends a frame to its default gateway.
2Router10.0.0.20Not yet selectedThe router removes the incoming frame and looks up the destination IP address.
3Router10.0.0.20MAC address of Host B on the 10.0.0.0/24 networkThe router matches the 10.0.0.0/24 route and creates a new Layer 2 frame on the interface toward Host B.
4Host B10.0.0.20Host B's own MAC addressHost B receives and processes the packet.

Host C does not receive or need to process this routed communication. It is in a separate network, and the router selects only the interface that leads to Host B's destination network.

Broadcast Domains and Collision Domains

A broadcast domain is the group of devices that receive the same Layer 2 broadcast traffic. By default, a router does not forward Layer 2 broadcasts from one interface to another. Each router interface therefore creates a separate broadcast domain.

Each router interface is also a separate collision domain. A collision domain is a network segment in which simultaneous transmissions could collide. Modern switched and routed full-duplex links normally avoid collisions during ordinary operation, but the interface boundaries still separate these domains.

Broadcast-domain separation is useful because it limits broadcast traffic and isolates network segments. A broadcast generated in one routed subnet does not automatically spread into every other subnet.

Broadcast comparison

  • A normal Layer 2 broadcast can be propagated within the same switched VLAN.
  • A router interface does not forward that broadcast into a different IP network by default.
  • If two segments unexpectedly share broadcasts, they may actually be joined at Layer 2 through the same VLAN, or a special relay feature may be configured.

Router Use Case: LAN-to-Internet Access

A common router deployment connects a local area network to an Internet service provider or another upstream network. Client devices use the LAN-facing router address as their default gateway. The router provides the path from internal networks to external networks.

Consumer devices often combine several functions in one box:

  • Routing between the home LAN and the upstream network
  • Network address translation, or NAT
  • Firewall filtering
  • DHCP address assignment
  • Wireless access

These are separate functions. NAT is common on edge routers, but NAT is not the definition of a router and not every router performs NAT.

Router Versus Switch and Bridge

Device or functionPrimary OSI layerForwarding informationTypical scopeBroadcast-domain effect
RouterLayer 3IP addresses and routing tableBetween separate IP networksSeparates broadcast domains
Layer 2 switchLayer 2MAC address tableWithin a LAN or VLANNormally extends one VLAN broadcast domain
BridgeLayer 2MAC addressesConnects LAN segmentsNormally keeps connected segments in the same broadcast domain
Multilayer switchLayer 2 and Layer 3MAC tables and routing informationSwitches within VLANs and routes between themCan separate broadcast domains using Layer 3 interfaces

A switch or bridge generally forwards frames within a LAN based on MAC addresses. A router forwards packets between IP networks based on destination IP addresses and routing information. Modern multilayer switches can perform both Layer 2 switching and Layer 3 routing, so the hardware form factor alone does not always identify the device's function.

Basic Cisco IOS-Style Configuration

The following example assigns addresses to three router interfaces. Interface names vary by router model and lab platform.

configure terminal
interface gigabitEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 no shutdown
interface gigabitEthernet0/1
 ip address 10.0.0.1 255.255.255.0
 no shutdown
interface gigabitEthernet0/2
 ip address 172.16.1.1 255.255.255.0
 no shutdown
end

When these interfaces are configured and active, the router can create directly connected route entries for the three networks.

An optional default route toward an upstream router can be configured as follows:

configure terminal
ip route 0.0.0.0 0.0.0.0 203.0.113.1
end

Use an actual reachable upstream next-hop address in a real network. The address shown here is for instructional illustration.

Verification commands

show ip interface brief
show ip route
show ip route 10.0.0.20
show arp
ping 10.0.0.20
traceroute 10.0.0.20
  • show ip interface brief displays interface addressing and status.
  • show ip route displays the routing table.
  • show ip route 10.0.0.20 shows how the router would reach a specific destination.
  • show arp displays local IP-to-MAC mappings used for next-hop delivery.
  • ping tests reachability.
  • traceroute helps reveal the Layer 3 path toward a destination.

Troubleshooting Router Connectivity

A host reaches local devices but not another subnet

  • Verify the host IP address, subnet mask, and default gateway.
  • Confirm that the default gateway is in the host's local subnet.
  • Check router interfaces with show ip interface brief.
  • Inspect routes with show ip route.
  • Ping the local gateway before testing the remote destination.
  • Check for a subnet mask mismatch that causes an incorrect local-versus-remote decision.

The router receives traffic but cannot forward it

  • Check whether the destination network appears in the routing table.
  • Use show ip route and show ip route for the specific destination.
  • Confirm that the selected next hop is reachable.
  • Confirm that the outgoing interface is operational and not administratively down.

A remote ping fails even though the source router has a route

  • Verify the remote host's default gateway or return route.
  • Test the remote router interface before testing the host.
  • Check endpoint firewalls and other packet-filtering policies that may block ICMP.
  • Confirm that the destination host is online and correctly addressed.

Unexpected broadcasts cross a supposed network boundary

  • Check VLAN assignments and switch topology.
  • Confirm that the intended boundary is a router or Layer 3 interface.
  • Review any configured broadcast relay features.
  • Remember that separate switch ports do not necessarily mean separate broadcast domains if they belong to the same VLAN.

Exam- relevant Notes

  • A router is primarily a Layer 3 device.
  • Routers use destination IP addresses and routing tables to select paths.
  • Switches and bridges generally use MAC addresses to forward Layer 2 frames.
  • A host uses its default gateway for off-subnet traffic.
  • The default gateway must be reachable through the host's local subnet.
  • Routers do not forward Layer 2 broadcasts between interfaces by default.
  • Each router interface represents a separate broadcast domain and collision domain.
  • The destination IP normally remains the same across routed hops, while Layer 2 addressing is rebuilt for each link.
  • Longest-prefix match selects the most specific matching route.
  • NAT, DHCP, firewalling, and Wi-Fi may be included in a consumer router, but they are not what defines routing.

For a related reference, see What Is a Router?.