Router Operation – Understanding the Layer at Which Routers Operate

layer3layer4nat;routerrouting

I have studied from various sources that router is a layer 3 device. It does routing based on Network layer (layer 3) header, but I have a doubt.

Network address translation (NAT) is a feature of Router which is required for routing traffic. It does processing based on both Network layer and Transport layer (layer 4) headers. So why cant we say that router is a layer 3 & layer 4 device when it is processing layer 4 header also?

Best Answer

Network address translation (NAT) is a feature of Router which is required for routing traffic.

That is completely incorrect. NAT is a kludge (a clumsy, inefficient solution) designed to extend the life of IPv4 addressing until IPv6 is ubiquitous. NAT breaks the IP paradigm of end-to-end connectivity, and many things have problems with NAT. Routing works quite well without NAT. You should only use NAT were you absolutely must use it, e.g. private to public addressing, or for joining two networks with overlapping addresses.

It does processing based on both Network layer and Transport layer (layer 4) headers.

Again, no. Routing does not involve the layer-4 header. One form of NAT, NAPT (Network Address Port Translation), will use the TCP or UDP ports, or ICMP query IDs, but it only works for those three protocols, and it breaks other transport protocols and many applications. A routing table (what routers use to determine the path of packets) has nothing about layer-4 protocols in it.

RFC 2663, IP Network Address Translator (NAT) Terminology and Considerations explains NAPT:

4.1.2. Network Address Port Translation (NAPT)

NAPT extends the notion of translation one step further by also translating transport identifier (e.g., TCP and UDP port numbers, ICMP query identifiers). This allows the transport identifiers of a number of private hosts to be multiplexed into the transport identifiers of a single external address. NAPT allows a set of hosts to share a single external address. Note that NAPT can be combined with Basic NAT so that a pool of external addresses are used in conjunction with port translation.

For packets outbound from the private network, NAPT would translate the source IP address, source transport identifier and related fields such as IP, TCP, UDP and ICMP header checksums. Transport identifier can be one of TCP/UDP port or ICMP query ID. For inbound packets, the destination IP address, destination transport identifier and the IP and transport header checksums are translated.