Concept of router’s working.

routerWhen you are reading this article, you understand what mean wireless network router and why do we use it, but no one knows how it works, doesn’t it? In this article I will try to use as much as possible accessible language to tell you about basic principles of router’s working.

The most basical router function is NAT

NAT is used to replace IP addresses. Internal networks are mostly use addresses like 192.168.1.XXX (for example: 192.168.1.1) and this makes problem of routing in global Internet, because it’s necessary that IP address aren’t duplicated. NAT is good solution of this problem. LAN computers connect to internal interface of router, take an IP address and gateway. Router’s WAN interface connects to Internet. Now let’s consider algorithm of NAT translation: Firstly, request is made from any internal network computer. As example: when you are trying to visit any website, computer sends this request to gateway address. Router receives this request, notes your computer as initiator of connection, creates a copy of your package and sent to destination address, but using different router and it’s IP address. Your packet will be destroyed. Server, that was sent request, processes it and sends answer for a router’s address. Router has been waiting for, because it has made note that answer on your computer’s request will be sent. Router sends it to your computer. As you can see, initiator of connection can only be computer of local network and response from server gets to computer only if router will wait for response to request. All attempts to connect  from outside will be stopped at router and will be successful only if router provides a resource for the requested port, or he has configured Port Forwarding rules, which we will discuss.

Port forwarding

Port forwarding is process like NAT, but in different direction, and consequently only static NAT. I mean certain requests to certain computers, because in router’s IP address can’t be known in the global network. As example: you set up an FTP or HTTP server to your PC and you want to ensure access to data resources. You need to prescribe rule in router, which will indicate that all incoming on correct port packets  will be transferred on IP address of our computer on specified port (port can be changed). NAT – DMZ. NAT – DMZ is similar as Port Forwarding, but it is needed to register a rule for every port. You just need to configure NAT DMZ that will forward to correct computer all incoming to WAN router calls. You can’t change ports.

router scheme

 

Routing

We can say that Routing is the same as NAT, but in both directions. For routing process there are should be more than 2 LAN interfaces (interfaces aren’t ports) with different address spaces (one interface’s IP is 192.168.0.1, other is 192.168.1.1). So computers which have same network will receive IP address like 192.168.0.XXX, computers from other network will receive 192.168.0.XXX. As result, they will have different gateways like 192.168.0.1 and 192.168.l.l. It’s two-way routing.