What is the IP address, network mask, gateway?

Exchanging data between at least two computers requires a dedicated computer network has to be created. In such a network, the devices communicate using appropriate transmission media and communication protocols. Not only computers and servers can be connected to a computer network these days, but also CCTV equipment, alarms, smart home components or household appliances.
When configuring network interfaces of that equipment, the user is prompted to enter dedicated network settings. The most common parameters to enter include:
  • IP address
  • Subnet mask
  • Gateway
  • DNS
  • Ports (for specific services).
IP address
IP address is the host identification number used for proper communication between devices. The IP address is a number assigned to a network interface, a group of interfaces (broadcast, multicast addresses) or to the entire computer network, used to identify network components and being one of the elements enabling them to communicate.
Two IP address versions can be distinguished:
  • IP version 4 (IPv4) – the IP address is a 32-bit number (from 0 to 4294967295), written in big endian format (data notation in which the most significant byte is placed first). The address is written as 4 separate bytes, called octets, since they have eight bits in a binary form. Those eight bits give 256 combinations, so each octet represents a number from 0 to 255.
    The most common method to write IP addresses is to present them as 4 numbers from 0 to 255, separated by periods. In fact, computers consider the DIPOL website address as a 32-bit number: 1048150566. Such notation is hardly readable, so the IP address is divided into four octets.
    The website address www.dipolnet.com written in binary format:
00111110011110011000001000100110
(decimal notation: 1048150566)
    Division into 4 octets: 00111110.01111001.10000010.00100110
    After converting four 8-bit groups to a decimal format, a more readable address is created:
62.121.130.38
    Due to the finite number of addresses and the need to aggregate them for a simplified routing, Regional Internet Registries (RIRs) have been created. These are organizations which allocate address pools to Internet service providers ( ISPs). The most important organization is the Internet Assigned Numbers Authority IANA) which deals with the distribution of individual address fields. The regional organizations include:
    • APNIC ( Asia Pacific Network Information Center) – Asia-Pacific region,
    • ARIN ( American Registry for Internet Numbers) – North America region,
    • LACNIC ( Regional Latin-American and Caribbean IP Address Registry) – Latin America and the Caribbean Islands,
    • RIPE ( Réseaux IP Européens) – Europe, the Middle East and central Asia region,
    • AfriNIC – Africa region (launched on February 22, 2005, before that, the distribution was dealt with by RIPE NCC, APNIC and ARIN).
      For IPv4, it was initially decided to divide all IP addresses into five address classes:
      • A – large organizations (127 networks – 7 bits) with a very large number of hosts (16 million – 24 bits),
        1 bit per class definition,
      • B – a large number of organizations (16 thousand networks – 14 bits) with a large number of hosts (65 thousand – 16 bits),
        2 bits per class definition,
      • C - small organizations (2 million networks – 21 bits), small number of hosts (256 – 8 bits),
        3 bits per class definition,
      • D – group distribution of packets,
      • E – reserved for research purposes.
      Since 1997, the division into network classes is outdated and no longer in use. Currently, the IPv4 addresses are allocated regardless of network classes. The division is no longer used by devices, and the class roles have been taken over by subnet masks. Nowadays, the entire Internet relies on the so-called Classless Inter-Domain Routing (CSDIR).
    • IP version 6 (IPv6) - IP address is a 128-bit number not in decimal but in hexadecimal code. That means that the IP address consists of eight groups of digits, four digits from 0 to F in each group. Unlike the previous protocol version, the address range, i.e. the area of its visibility, is limited by the appropriate prefix.
      The IPv6 address pool available is 2128 which gives 340 282 366 920 938 463 463 374 607 431 768 211 456 addresses.
      The IP address is written as eight 16-bit blocks in hexadecimal format separated by colons. The initial zeros in a block, and one block sequence containing zeros only, can be skipped.
      The skipped blocks of zeros are marked with a double block separator (a colon). Only one double colon "::" is allowed in the address. An example below: equivalent address notations of the 2003:0db8:0000:0000:0000:0000:1428:57ac address:
      • 2003:0db8:0:0:0:0:1428:57ac
      • 2003:0db8:0:0::1428:57ac
      • 2003:0db8::1428:57ac
    Subnet mask
    The subnet mask (for IPv4), as the IP address version 4, is a 32 bit number (for IPv6 it has 128 bits). The mask is used to distinguish the subnet part of the IP address, as well as the part that is the host address of that subnet. The subnet mask has a very specific structure. It begins with a sequence of ones and then turns into a string of zeros – the part with ones is the network part of the mask, while the string of zeros is the so-called host part.
    For the IPv4, it is most commonly written in a form of four 8-bit numbers in decimal format and separated by periods (for example 255.255.255.0). The mask value has to be known to all routers and computers in a given subnet. As a result of comparing the address mask (e.g. 255.255.255.0) with a specific IP address (e.g. 192.168.1.122), the router is notified which part of the address identifies the subnet (in this case 192.168.1.), and which refers to the device with that IP address assigned (address ending: .122).
    A short notation of the mask, in a form specifying the number of initial bits with the value 1, can often be found. For the IP address 192.168.1.249 and mask 255.255.255.0, the short notation is:
    192.168.1.249/24
    The table below compiles information on the subnet mask size (the number of bits in the network-related part of the address), and the corresponding number of available IP addresses within a given subnet. Note! The number of hosts is lower by 2 than that of the IP addresses allocated to a given subnet (2 addresses are occupied by the so-called network address and the broadcast address for a given network).
    Subnet mask
    Short designation
    Number of IPs
    255.0.0.0 /8 16777216
    255.128.0.0 /9 8388608
    255.192.0.0 /10 4194304
    255.224.0.0 /11 2097152
    255.240.0.0 /12 1048576
    255.248.0.0 /13 524288
    255.252.0.0 /14 262144
    255.254.0.0 /15 131072
    255.255.0.0 /16 65536
    255.255.128.0 /17 32768
    255.255.192.0 /18 16384
    255.255.224.0 /19 8192
    255.255.240.0 /20 4096
    255.255.248.0 /21 2048
    255.255.252.0 /22 1024
    255.255.254.0 /23 512
    255.255.255.0 /24 256
    255.255.255.128 /25 128
    255.255.255.192 /26 64
    255.255.255.224 /27 32
    255.255.255.240 /28 16
    255.255.255.248 /29 8
    255.255.255.252 /30 4
    255.255.255.254 /31 2
    255.255.255.255 /32 1
    The mask determines how many subsequent bits in the IP address form the network address. The remaining bits, however, specify the addresses of a particular host in the network (end device address). Where the bit in the mask is set to 1, the corresponding bit of the IP address belongs to the network address, and when it equals 0, the corresponding bit of the IP address belongs to the host address.
    The subnet mask bits are always set to 1, starting with the most significant bit (commonly the oldest), for example:
    IPv4 address: 192.168.10.111 = 11000000.10101000.00001010.01101111
    subnet mask: 255.255.255.0 = 11111111.11111111.11111111.00000000
    As seen in this case, the network address is:
    network address 192.168.10.0 = 11000000.10101000.00001010.00000000

    Example of calculating the network and broadcast addresses
    While calculating a network address, and when the device IP address and mask are available, the AND function should be applied (the result contains one when there is one in both strings):
    IP address: 192.168.11.189 in binary notation: 11000000.10101000.00001011.10111101
    Mask: 255.255.255.128 in binary notation: 11111111.11111111.11111111.10000000
    Result of AND operation in binary notation: 11000000.10101000.00001011.10000000
    The result of the AND function is the network address which, after conversion to decimal, has the form: 192.168.11.128.
    Knowing the subnet address, the broadcast address can be easily calculated. To this end, the mask bit negation is used, and the resulting number is added to the network address:
      Binary  Decimal
    Mask 11111111 11111111 11111111 10000000 255.255.255.128
    NOT operation 00000000 00000000 00000000 01111111 0.0.0.127

     

    Every octet has to be added to its corresponding octet of the network address. Since the first 3 octets are 0, just the last one is added: 128+127=255. The broadcast address sought in this network is therefore: 192.168.11.255.
    IP addresses in the range between the network and broadcast addresses are dedicated to the hosts. In the example shown, these are:
    First host 192.168.11.129 in binary notation: 11000000.10101000.00001011.10000001
    Last host 192.168.11.254 in binary notation: 11000000.10101000.00001011.11111110
    The address range 192.168.11.129 - 192.168.11.254 allows for connecting a maximum of 126 hosts.
    Of course, the IP address ranges do not have to be calculated manually. Dedicated calculators, also available for mobile devices, are of help:
    IP and Subnet Calculator
    IP Network Calculator
    Gateway
    The gateway is a network device that acts as an entry point from one network to others. The host sends all packets directed to other hosts outside the local network to the default gateway (specifically to the gateway IP address), which means that a host without the default gateway address can only exchange packets with computers in the same local network. Due to the widespread use of the TCP/IP network, the concept of a gateway has become virtually parallel with a router.
    The gateway is created at the network border to manage communication of all data exchanged between the internal network and the external ones. In general, for simple home networks, the gateway acts as a securing device for the local network while connecting it to public networks.
    When setting an IP address for a gateway (from the local network side), the first available address in the pool of host addresses in the given network is usually used.
    DNS
    To change public (external) IP addresses from numeric to a domain format, the DNS (Domain Name System) service is used. Hence, there is no need to remember the addresses e.g. in the 62.121.130.38 format, but just a much more friendly www.dipolnet.com instead. Translation of numeric to domain is performed by an appropriate DNS server to which the computer sends a translate request. After receiving a response with a numeric address, connection is established with the appropriate computer.
    1. What is the IP of www.dipolnet.com (query to the DNS 8.8.8.8 server)?
    2. www.dipolnet.com 62.121.130.38
    3. Hello, 62.121.130.38! Send me your website
    4. Here is my website

    Overview of a communication procedure between the client and server using DNS addresses
    Network ports
    The protocol port is a term related to the TCP/IP protocol used in the Internet to distinguish a number different services and connections. Protocol ports are marked with integers ranging from 1 to 65535. Some ports (from 1 to 1023) are reserved for standard services, e.g.:
    • 53 - DNS
    • 20 - FTP – data transfer
    • 21 - FTP – sending commands
    • 67 - DHCP – server
    • 68 - DHCP – client
    • 79 - Finger
    • 70 - Gopher
    • 80 - HTTP
    • 443 - HTTPS (HTTP to SSL)
    • 143 - IMAP
    • 220 - IMAP3
    • 3306 - MySQL
    • 119 - NNTP
    • 110 - POP3
    • 995 - POP3S (POP3 to SSL)
    • 25 - SMTP
    • 22 - SSH
    • 23 - Telnet
    • 69 - TFTP
    For example, if a host is also a web server, it has to open the port 80 when web resources have to be shared with another host.