A network router fundamentally routes IP packets based on their IP address to network subnets where the host with the target IP address resides. Routers work at Layer 3 (network) where network switches are (layer 2) and Ethernet hubs are (layer 1).
Routers are special computers which inspects each IP packet and compares the target address to an IP routing table and forwards packets based on the routing table. Routers usually include routing protocols which maintain the routing table automatically. Routing protocols include RIP, OSPF and BGP.