A switch connects computers together. As an example we set up a switch to create a network. When computer A wants to speak to another computer B, it sends the packet to the switch (it has the recipients IP address). If the IP address is located on the same subnet, the switch knows where computer B is. Else, it will route the request to its gateway. Let's say the local network is at 192.168.0.xxx with subnet mask A request to is outside the subnet, and will route the request to the ISP (gateway).

Say we have two switches, each creating their own networks: Network 1 (192.168.0.xxx) and Network 2 (192.168.1.xxx). Computer A ( wants to talk to Computer B ( Am I correct in saying that we need a router to do this? So Router 1 will have to connect to a router which also connects to Router 2.

If this is the case, the only difference between a router and a switch (at this level), is that a switch chooses the output port based on the recipients address, while a router is based on the IP + subnet mask. In other words the switch has one output port for unknown subnets, while the router has got multiple.

Routers can also have NAT enabling them to connect a local network to the internet. This makes the router a "man-in-the-middle". A router can also have a firewall built in.

Is a router just a switch with more features and more advanced routing capabilities?


No, switches are not just simplified routers. Although many devices combine functions of both routing and switching, the two functions are distinct. Switches create networks, routers connect distinct networks together. Switches operate using only MAC-addresses, while routers also use IP addresses. Switches have many ports in the same subnet, while routers can only have one port per subnet. Devices that combine these functions still maintain a distinction between routing and switching, as they will separate 'switched' ports from 'routed' ports due to the requirements of the different functions and hardware.

To show some of the nuances: professional grade routers will perform internal switching functions (such as CEF), and some 'layer 3' switches Route (if they are layer-3 switches), but the operations are distinct.

It is useful for anyone interested in networking to become familiar with the OSI Model, which describes how computers and other devices talk to each other. The OSI Model breaks communication into seven layers, including the Application layer, which is the program you, the human, are working with, the Network layer or Layer-3, which deals with IP addresses and Routing, and the Data Link layer, or Layer-2, which deals with physical hardware addresses. Also, when you hear terms like TCP, ports, sockets, sessions, etc., these are also represented by the OSI model, so it's useful to learn.

Routers operate with IP addresses at the OSI Layer-3 or Network Layer and Switches operate with MAC addresses at the OSI Layer 2 or Data Link Layer.

Some devices, such as consumer wifi-routers, combine both a switch and a router in the same device (for instance a wifi router with 5 extra ports on the back). Other devices, such as cable or DSL modems, still function as a router because they route packets between your local network, and the remote network, and perform layer-3 functions such as NAT.

The operations of Routing and Switching are distinct however, and operate on different layers of encapsulation, different OSI layers, and with different addresses, as described below:

In detail:


We will start with a Layer-2 Switch. This is your standard switch, that includes all un-managed switches, and even managed switches that only operate at the Data-Link layer. This switch receives frames and compares them to a MAC-Address-Table (which is distinct from the ARP table in that it has MAC Addresses and Ports, rather than MACs and IPs). It uses this information to forward frames either to one, many, or all ports depending on whether it is a unicast, multicast, or broadcast frame. If it is a unicast frame, but it does not know which port to send it to, it floods it to ALL ports, except the port the switch received the frame on. Of course there is more detail with CAM tables and VLANS, but in short: Switching moves frames based on hardware addresses, switching can only move frames within the same subnet.


A router routes between subnets. In fact, on a router, you cannot put multiple routed interfaces on the same subnet - because a routers function is to move packets between layer-3 subnets. The router thus receives frames, containing packets off a port. If frame's destination (mac-address) matches the router (either as unicast or broadcast), the router will then look at the IP-packet contained inside the frame, and make a routing decision based on the IP and subnets. Once the routing decision is made, a switching decision is made to determine which port and layer-2 destination to send the packet to, so it can be re-encapsulated at Layer-2. For more information about the switching conducted by the router, see Cisco Express Forwarding, for example.

How the computer gets through the gateway:

So how does the computer reach its gateway? The computer itself has a route to its gateway. It knows that "if an IP is not on my subnet, I need to send the packet to this gateway address to get out," Thus, since all devices process top-down through the OSI-model, the computer will do an internal routing lookup first (layer-3) to decide wither a device is within its subnet. If not, it will arp (layer-2) to find the mac-address of the default gateway, and will encapsulate the IP packet for the remote host within a frame addressed to the router. The frame will be switched across the network using layer-2 headers and MAC addresses, within the same subnet, until it reaches the router, where its layer-3 IP addresses are looked at, and the decapsulated packet is routed between subnets.

Layer-3 Switches

The other scenario I haven't covered is the Layer 3 switch. These switches operate the same way as described above. They are switches, but they can have specific ports, physical or virtual, designated as routed ports. These routed ports operate as gateways between subnets, (often VLANs within a switch) while the switched ports continue to only operate at Layer-2.

Part of the distinction between layer-2 and layer-3 devices is reflected in the hardware and memory of the devices. As Cisco explains, layer-2 only devices have a CAM (content addressable memory) table containing the MAC-Address-table. Layer-3 devices additionaly have a TCAM table, which handles mapping between routing, layer-2 and layer-3 addresses. Because of the physical hardware differences, you will see price differences in hardware that is a pure layer-2 switch, a layer-3 switch, and a router.

  • Thank you for an in depth answer! If we have a local network built with multiple switches (layer 2), they will "slowly" build up a MAC table. So each computer on this network will need to know every computers MAC to be able to communicate? So if it knows the IP of a computer, it needs to map that to a MAC first? Nov 25 '14 at 15:08
  • 1
    The computer has to know the MAC of the Gateway, which is the router, yes. It can find this out through and ARP request. This is why when you do DHCP, or manually configure a computer's IP, it asks you for the IP of the gateway. Given the IP, it can find the MAC. ... Once the router receives the frame, it RE-ENCAPSULATES it, or wraps it, inside of a new frame on the remote network, containing the source MAC of the router, and the destination MAC of the remote computer.
    – glallen
    Nov 25 '14 at 15:14
  • 1
    Somewhere, there is a router. Whether it is your router, or the ISPs. A cable/DSL modem acts as a router, because it provides a local subnet for your home, provides a gateway address, and routes to external networks. If the whole neighborhood was in the same subnet, they could communicate with IPs within that subnet. The OSI Model still applies, the computers will still want layer-3 addresses. The exception is with point-to-point modem or serial links, which are rare these days.
    – glallen
    Nov 25 '14 at 15:39
  • 1
    Well, internally a cisco router for instance uses CEF and CAM tables to do mac-to-port translations after it has done it's routing lookups, then it uses these tables to avoid having to do the routing decisions again for subsequent packets with the similar headers, and effectively switches. Maybe not with a unmanaged netgear switch, but with managed enterprise networking hardware it does become nuanced. My answer reflects this.
    – glallen
    Nov 25 '14 at 17:34
  • 1
    It's hard to be simple, ++1 for "switches create networks, routers connect distinct networks together"
    – elsadek
    Jan 8 '16 at 17:07


Switches do the following:

  • When something comes in on a port, it looks at the destination MAC address of the Ethernet frame it receives
  • It looks in its CAM table for the MAC address.
  • If it has seen that MAC address before, and knows what port the destination MAC is connected to, it forwards (resends) the frame out that port.
  • If it has not seen that MAC address before (either a new MAC or the MAC "aged out" of the CAM table), it forwards the frame out of all ports, like a hub.

It does nothing based on IP addresses. Switches don't even look at the IP addresses. You can use other technologies besides IP on a switch, such as IPX.

Routers (specifically IP routers if you want to be pedantic) do things based on IP addresses. An IP router does the following:

  • When something comes in on a network adapter, it looks at the destination IP address.
  • It compares the address against each entry in its routing table, or Forwarding Information Base (FIB). Entries look like this: via

    This means you can reach the subnet via the NIC that's assigned IP address (which better be a local NIC on the router).

    Entries can come from the IP/subnet mask assigned to local NICs (if your NIC is assigned, you get a "free" route to, information given by DHCP, and information given by routing protocols such as RIP, OSPF, and BGP.

  • It will find the most specific FIB entry (the one with the highest subnet CIDR number) and forward (resend) to that IP. If there are two entries going to the same subnet, it may pick one and stick to it, or try to load balance between them.

  • If there is no matching FIB entry, it will use a default gateway entry if there is any, otherwise it will drop the packet.

While it is common for switches to be the only function in a device, many consumer-class routers include a switch - it's really two devices in one.

  • 1
    That was what I missed. The fact that switches don't look at the IP, and that home routers include a switch. +1 Nov 25 '14 at 16:28

Network 1 (192.168.0.xxx) and Network 2 (192.168.1.xxx). Computer A ( wants to talk to Computer B ( Am I correct in saying that we need a router to do this?

If the networks are separate or are on different subnets, then yes you would need a routing device to get the data to transverse the networks.

Is a router just a switch with more features and more advanced routing capabilities?

Traditional (unmanaged) switches are layer 2 devices while routers reside on layer 3. Some managed switches have layer 3 capabilities, but are not considered routers. If you were to go to the store and buy a wireless router, you are not just buying a "router" you are in fact buying three devices: a router, a switch, and an access point. The access point is basically another port on the switch, except it provides a wireless signal rather than and ethernet port, and the router connects the LAN switch to the WAN port. On a home device, the only thing that makes the hardware a router, is the software that is running on it.

However if you look at the enterprise level equipment, you'll notice that you can buy very specialized devices. You can buy just an access point, or just a firewall, or just router, etc... Here is one example of an enterprise grade router. Notice that there are only 4 Ethernet ports, two is for the console/AUX, and the other two are for the router, but they are not labeled "LAN" or "WAN". There are also 4 other slots that different cards can plug into, DSU/CSU, DSL, coax, etc... All of these are can be considered as separate networks and the router manages the data between all of them.

Since a router is a layer 3 device, it would make sense that it also has layer 2 capabilities. However routers mainly server on layer 3 and are therefore not considered to be a switch. Similar to that a big 18-wheel truck can get you to the grocery store every Saturday morning to buy a gallon of milk, but that not what they are generally used for so we don't call them grocery getters or family vehicles.


Definition: Routers are small physical devices that join multiple networks together. Technically, a router is a Layer 3 gateway device, meaning that it connects two or more networks and that the router operates at the network layer of the OSI model.

Home networks typically use a wireless or wired Internet Protocol (IP) router, IP being the most common OSI network layer protocol. An IP router such as a DSL or cable modem broadband router joins the home's local area network (LAN) to the wide-area network (WAN) of the Internet.

By maintaining configuration information in a piece of storage called the routing table, wired or wireless routers also have the ability to filter traffic, either incoming or outgoing, based on the IP addresses of senders and receivers. Some routers allow a network administrator to update the routing table from a Web browser interface. Broadband routers combine the functions of a router with those of a network switch and a firewall in a single unit.

Switches are Layer 2 (of the OSI model) devices.

  • Thank you for your quick answer. As I understand it, switches could be used instead of routers in homes. It would create a local network, and give access to the internet. If a computer on the local network tries to contact a computer outside the subnet mask, it will be sent to the gateway (ISP). Are there any differences in terms of functionality? Nov 25 '14 at 14:21
  • You need a router at your home to connect your Local Network with your ISP, switches used for connectivity on same network, routers to connect different networks together. if i helped, please approve my answer.
    – gmetax
    Nov 25 '14 at 14:24
  • Why wouldn't a switch do the job? If a computer behind the switch tries to access, wouldn't the switch simply pass the request on to the ISP? Nov 25 '14 at 14:37
  • how are you gonna be connected with the ISP ? with Ethernet?
    – gmetax
    Nov 25 '14 at 14:40
  • 1
    yeah i know, i was trying to give him simpler answers, 'wifi-routers' are more complex than the people believe, (router,accesspoint,switch)
    – gmetax
    Nov 25 '14 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.