IP Addressing and Routing
Written by Ian Elliot   
Friday, 25 February 2022
Article Index
IP Addressing and Routing
Routing Protocols


Routing Protocols

What does the router do when it has identified a packet that doesn’t belong on your local network?

It passes it along to another router which, it hopes, does know how to send it to its destination. Routers are part of the architecture of the Internet and they “talk” to each other using one of a number of special protocols – RIP (Routing Information Protocol) is the most common - and pass information on about the routers that they are connected to. You can also add your own “routes” manually if you think you know better.

For most users routing protocols are fairly irrelevant. If you have a connection to an ISP then the router will simply forward all external packets to the ISP’s router, which is expected to take care of everything beyond this point.

To make it all work all you have to do is add a suitable router and give it the necessary information about its IP address and how to connect to the ISP. After these simple steps packets sent to it will be correctly routed. You also have to set up the client PCs on your network to use it as a “gateway” i.e. the place to send all non-local traffic but this  is all fairly easy.

Dynamic DNS

Everything works as described as long as your local network has a block of IP addresses it can use out on the Internet.

In practice IP addresses are in such short supply, in fact allocations of new addresses are about to run out,  that this isn’t usually the case.

The latest version of the Internet Protocol IP v6 (see later) might well be the long-term solution to the IP address shortage but for the moment it still not very common.

There are blocks of IP addresses that are assigned for the use of “internal” networks and these are not regarded as valid Internet addresses. There are three blocks of IP Addresses set aside for use within private networks       -      -

and    -

You can safely use these as internal addresses and allocate them to machines as you wish. However to connect to the Internet you need a valid external Internet address and these are hard to come by.

The way that we get around this problem is to dynamically assign external IP addresses as and when they are needed. When you log on to your ISP, an IP address is assigned to you from a pool of addresses allocated to the ISP. This allows the block of addresses to be shared and reused and the only problem is that you are unlikely to get the same address each time.

Dynamic IP address assignment only causes a problem if you want to run, say, a web server for others to connect to. The problem is how can they know what IP address to use if you are not connected because one hasn’t been assigned to you yet!

The solution to the dynamic IP address assignment problem is to use dynamic DNS or dDNS. The DNS - Domain Name System - is just a big distributed lookup table that is used to convert a URL to an IP address. When you use a URL like www.example.com the system lookups up www.example.com using DNS and converts it into an external and routable IP address.

For public fixed IP addresses this all works very simply - you register a domain name and tell the DNS system what IP address is corresponds to. Of course the actual details are a little more complex in practice but this is the principle.

Now how can we make the DNS system work with a dynamic IP assignment?

The answer is that when a router makes a connection to the ISP it is allocated a new IP address which it will use as the source, i.e. return address in any IP data packet. That is it knows what IP address it has been allocated and it can run a small program that informs a dynamic DNS server of its new IP address. That's all that is needed. In practice dynamic DNS works well enough for many small server based applications such as web cameras etc.

So you don't need a fixed IP address. But this only solves the problem for the router - what about the all of the local computers connected to it that have non-public and hence non-routable IP addresses?

The solution is NAT.



NAT, or Network Address Translation, takes dynamic IP address allocation a step or two further. The problem that NAT aims to solve is that every data packet has two addresses - the destination and the source. The destination is simply the public IP address of the machine the packet is on its way to. The source address is the return address that the remote server uses to send a response packet back to the machine that initiated the exchange.

The problem is that while the router has an external IP address and so a response can be sent back to it how does it now which of the machine on the internal network the packet should be sent on to? This is the purpose of NAT - to allow a return path to be included with any outgoing data packets.

There are a number of different forms of NAT.

The first takes IP addresses on your local network and substitutes for them using a block of IP addresses that you have been allocated. This is just the same dynamic IP allocation that ISPs use but built into a local router. This is a very simple and reliable form of NAT but it has one huge problem all of the IP addresses used have to be public addresses. All that happens in this form of NAT is that a machine in the internal network gets the use of an external address of the duration of a packet exchange with a remote machine.

The most commonly used form of NAT is “overloading”. This makes use of a single Internet public IP address and maps all of the internal addresses to it.

How is this possible?

The answer is that all data packets not only have an IP address but a “port number”. The port number is supposed to identify what the data is to be used for.

For example, all web data is transferred using port 80, FTP connections are made using port 25 and so on. There are 65536 ports and what NAT with overloading does is to use the port numbers to code where the packet came from.

The IP address determines which machine the data packet is intended for and port numbers are used to determine which application on that machine the data is for. The router however can use port numbers to customise its one return address - i.e. the public IP address it is using . That is the remote machines sends a data packet back to the router but in this case the port number is used to identify the machine on the local network the data was intended for. The router also has to remember the port number that the local machine's request was made on and substitute this back into the data packet.

Last Updated ( Saturday, 26 February 2022 )