Linux networking concepts using CentOS

A network is a group of two or more computers or computing devices connected using any communication media, such as cables or wireless media. These devices may be located in the same geographical location or spread across the world. A network environment provides these three services:

  • Enables connected devices to communicate with each other
  • Enables multiple users to share devices such as printers, copiers, scanners, and so on over the network
  • Enables the sharing of files and managing of information across computers

Most organizations use two types of network: one for communication with internal staff and another for the outside world. Intranet is the term used to define communication within the internal network of an organization and internet is used for external communication. The internet is also the largest network in the world and is popularly known as a network of networks.

Common terms used in Linux networking

This section describes the various terms that are used to define computing devices and networking terminologies used in Linux.

IP address

Each device connected to a network must have at least one unique address that is used to identify that device on the network. This address is known as the IP address and it is essential for routing the packet from the source to the destination through the network. Information or data over the network is transferred in the form of packets. Each packet has a header attached to it containing the information required to route the packet from the source to the destination. There are two different types of IP address schemes available, called IPv4 and IPv6.


IPv4 is a 32-bit logical address used by computing devices to communicate with each other using the TCP/IP protocol stack. It is generally expressed in the decimal notation of four octets, with each octet containing 8 bits separated by a dot. The value of each octet can vary from 0 to 255. This address can further be broken down into two parts; for example, a network part and host part:

  • Host part: The host part is used to identify a host on a subnet. No two hosts on the same subnet can have the same host part.
  • Network part: The network part is used to identify a subnet. Hosts on the same subnet can communicate to each other without needing a router.

By using 32 bits for addresses, we can have a maximum of 4.3 billion unique addresses, many of which are reserved and cannot be used. Hence, to meet future requirements, IPv6 with an 128-bit address was created.


IPv6 uses 128 bits for addressing. It is expressed in eight octets, containing 16 bits each, separated by colon. The use of 128 bits provides the 3.4 × 1038 unique addresses. The shifting of networked equipment and addresses from IPv4 to IPv6 requires a lot of understanding and effort. IPv6 does not have a broadcast address.

We will be restricting our discussion in this chapter to IPv4, as it is still more widely used and you will encounter it the most while performing networking.

Different classes of IP addressing

IPv4 addresses are divided into five public classes named A, B, C, D, and E, and three private IP address classes.

Public classes

There are five different public IP address classes from A to E. Here, classes A, B, and C are divided into two parts: network address (short for Net ID) and host address (short for Host ID). Net ID identifies the network and Host ID identifies the host on the network as shown in table here:

Public class

Octet 1

Octet 2

Octet 3

Octet 4


Class A

Net ID

Host ID

Host ID

Host ID to

Class B

Net ID

Net ID

Host ID

Host ID to

Class C

Net ID

Net ID

Net ID

Host ID to

Class D

Multicast address to

Class E

Reserved for the future to

Private classes

The following three IP address ranges are reserved for private use within the internal network of an organization. These IPv4 addresses can be used within a network, campus, and so on, and are not routable on the internet. Hence, if any packet contains any of these private IP addresses, it is dropped by the routers. Generally, the NAT mechanism is used for communicating with the public IPv4 address space when machines are working on private IPv4. The following table lists the private IPv4 address classes along with their address ranges and some special IPv4 addresses, such as link-local address and loopback address:

Private class

Address range

Subnet mask

Address block

Class A to /8

Class B to /12

Class C to /16

Loopback address to /8

Link-local address (APIPA) to /16

Loopback address is a special address that always points to local system (localhost) and is used for the testing of various services. The network is a loopback network of the local system. It enables server-client communication on a single system.

Link-local address or APIPA

The link-local address or Automatic Private IP Addressing (APIPA) is used if a machine connected in a DHCP environment is unable to acquire an IP address from the DHCP sever. This also helps in establishing communication between machines on the same network by allocating them IP addresses in the range of, if the DHCP server is not connected or down.


Netmask is used to identify a subnet. Binary AND operations of the 32-bit Host IP address with 32-bit netmask yields the network part of the address. The lowest possible address on a subnet is all zeros in the host part; it represents the network address. The highest possible address on a subnet is all ones in the host part; it represents the broadcast address for all hosts on a subnet. It is expressed in two forms. The conventional syntax uses a decimal representation of the network part while the new syntax uses CIDR notation to represent the network prefix (number of ones in the network address). For example, we can represent a 24-bit netmask in both these forms as shown below:

  • Conventional form255.255.255.0
  • CIDR notation/24

Let us assume that we are having following IP address and netmask information with us:

  • / 8
  • / 24

Now, using the above limited information we can find other related network information such as network address and broadcast address as given in the next table:

Network information for system having these details : / 8

Information description


IP address (host address)

Netmask (network prefix)

Network address

Broadcast address


Network Information for system having these details : / 24

Information description


IP address (host address)

Netmask (network prefix)

Network address

Broadcast address


A gateway is generally a router device or computer that is used to connect two or more dissimilar networks. In the case of Linux, it is the entry in the kernel routing table that is used when none of the route entries are matched.


Hostname is a human-readable name associated with a machine IP address. A DNS server is used to map the hostname to the IP address and vice versa. We can view the hostname of any machine by typing hostname command without any argument as shown below:

$ hostname
Every machine has got a special hostname that is, localhost associated with the loopback IP address This address is used for testing various services on the system.


Nameserver is also known as the DNS server. The purpose of the DNS server is to convert the hostname to an IP address and vice versa. There is a default fixed order of files, which are looked up when doing DNS lookup in CentOS 7. This order is managed by the rules written in the nsswitch.conf file and can be altered by an administrator. The following two files are looked up when resolving a DNS query in system:

  • /etc/hosts: The entries made in this file are first looked up before forwarding the query to the DNS server. It is a kind of local database of hostnames and IP address mappings. It is also quite useful for small isolated networks.
  • /etc/resolv.conf: If the answer of DNS query is not found in the /etc/hosts file, then the query is passed to the DNS server mentioned in /etc/resolv.conf. This file can be updated using dhclient or manually.

Following command is used to display the current settings of nameserver:

$ cat /etc/resolv.conf

After configuring the nameserver, verify the DNS connectivity using host command as shown here:

$ host


The NetworkManager is a GUI application used for the management of network settings. It comes with a daemon and Gnome applet to provide the network status and quick access for modification. The changes made using NetworkManager are stored in the /etc/sysconfig/network-scripts directory and thus it overrides any manual changes made there. If you want to configure the network connections manually by modifying the network scripts file, then NetworkManager should be disabled. NetworkManager provides a user-friendly method for manager network connections and is ideal for beginners.

Network interface naming conventions

Conventionally, network interfaces in Linux are enumerated sequentially as eth0eth1, eth2, and so on.

The following table list the traditional names of interfaces with their descriptions:

Interface name


eth0, eth1, and so on

Ethernet interfaces

wlan0wlan1, and so on

Wireless interfaces

eth0:1eth0:2, and so on

Alias interfaces

ppp0, ppp1, and so on

Dial-up interface


First-bonded network device


Internal bridge for virtual hosts


Loopback interface

Now, CentOS 7 has new default naming conventions. The interface name is based on hardware, topology, and device type.

The following table illustrates the network interface naming convention in CentOS 7:

Character in naming convention


First two characters represent type of interface

  • en: Ethernet interface
  • wl: Wlan interface
  • ww: WWAN interface

Next characters represent type of adapter

  • o: Onboard adapter
  • s: Hotplug slot
  • p: PCI card
  • x: MAC address

Last character is a number N, to represent an index, ID, or port

  • N: 0, 1, 2, and so on


If a fixed name could not be determined using new interface naming scheme then the old conventional naming scheme such as eth0 or eth1 is used. The example of new interface naming scheme is given here:

  • eno1: First embedded network interface
  • enp1s0: The first PCI card network interface with hotplug slot index 0
If the biosdevname feature is enabled in the server, then this naming scheme is overridden with a different naming scheme.

Related Articles

How to add swap space on Ubuntu 21.04 Operating System

How to add swap space on Ubuntu 21.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...

read more

Lorem ipsum dolor sit amet consectetur


Submit a Comment

Your email address will not be published. Required fields are marked *

6 − 6 =