IP address in action

LAN

  • Network ID = 202.120.10.0

  • Host ID = e.g. 42, or 164 (in this case)

  • IP = Network ID + Host ID

In order to interconnect LANs we need a router (interconnection happens through router).

The router interface that connects LAN to the router is called default gateway

  • must have same Network ID

  • usually has the lowest host address in LAN

  • in above case it will have IP 202.120.10.1

Ranges of addresses that are designed as private IP addresses:

127.0.0.0/8 subnet is reserved as loopback address

Subnet mask

Every TCP/IP host needs to know whether the destination IP is local or long distance. Subnet mask helps here.

Short notation for subnet masks:

  • 11111111.11111111.11111111.00000000 = /24 (24 ones)

  • 11111111.11111111.00000000.00000000 = /16 (16 ones)

Below picture shows how Subnet mask helps to understand that Computer A and B are in the same LAN.

If we need to send a request to another LAN:

  • send ARP request to realise MAC address of default gateway

  • IP packet will be sent to default gateway

CIDR (Classless inter-domain routing)

CIDR and subnetting are virtually the same thing.

Subnetting enables much more efficient use of IP addresses compared to class blocks.

example of subnet calculation

there is a cafe with network ID 192.168.4.0/24 and you need to split it to subnets.

  • start with a given subnet mask and mote it to the right until you have a number of subnets you need

  • forget the dots (never try to subnet without first converting to binary)

How many hosts we have on /24 subnet? 2^8 - 2 = 254

How many hosts we have on /26 subnet? 32 digits - 26 = 6 => you have 6 zeroes left after 26 ones => 2^6 - 2 = 62 hosts.

Original network ID: 192.168.4.0/24 translates to this binary (grey below):

By taking 2 more bits (red ones) for subnetting we can have 2^2 new subnets (we get 4 new Network ids).

DHCP (Dynamic IP addressing)

Usually routers are blocking broadcasting traffic, but what if in big company there are many subnets and just one DHCP server for convenience =>

DHCP relay

DHCP relay enables DHCP traffic (broadcast) to cross routers.

Last updated

Was this helpful?