A router is a computer whose software and hardware are designed to move data between computer networks. Routers move traffic to where it needs to go. They do this by choosing the shortest path between the computers using a complicated system of rules called routing protocols. Most routers have a specialized operating system, RAM, NVRAM, flash memory, and one or more processors. They also have two or more network interfaces. They come in a variety of sizes from something that could hold in the hand to something too large for one person to lift.
If a computer has an connection to the Internet, It is connected to a router that the computer sends data to. This is the first router the computer will connect to in order to get to the internet. It is known as a default gateway because it is the gateway to the internet. By convention, the gateway has the lowest IP address (like a phone number for a computer) in the subnet (a group of addresses). Anytime a computer make a connection (such as a connection to www.wikipedia.org), the IP address of the destination server is found using a service called DNS (Domain Name System). Once the destination address has been found, the computer connects to the gateway router. The gateway then sends data to a router at the ISP (Internet Service Provider). That router is a part of the internet and connects to other routers until the data reaches the destination.
In small networks such as homes, small businesses (including internet cafés) and small schools, the router also performs NAT (network address translation) which makes all outgoing connections look like they come from one address. Typically, incoming connections are only allowed if they are replies to connections made by a computer inside the NAT.
Routers connect two or more networks and direct traffic between them. These networks may be physical (the network is associated with a port) or logical (not associated with a port on the router). The term layer 3 switch often is used the same as 'router', but it is a general term without a technical definition. Layer 3 switch implies a device that is built to connect Ethernet devices in a LAN but can also perform routing.
Router operating systems are split into two parts: