August 10, 2020

Impact & Learning

Learn to impact

Network interfaces configuration in Linux

Read Time:3 Minute, 12 Second

In this tutorial, I will show how to create or modify a Network interface configuration in Linux. This procedure is essential to know the network interface through which we connect to the internet or local network, as well as its connection and configuration for a new connection to the network.

Configure a network interface

The configuration of network interfaces is essential for their identification and use by the network. Before proceeding with the configuration, it is important to learn to identify our existing network interfaces on the system, as well as their corresponding IP address.

The command to display the network interfaces as well as their IP addresses is the follow:

root@linus:~# ip address show

1: lo: mtu 17486 qdisc noqueue
     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
     inet scope host lo
     inet6 ::1/128 scope host
        valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000
     link/ether 00:0d:18:b2:b3:89 brd ff:ff:ff:ff:ff:ff
     inet brd scope global eth0
     inet brd scope global eth0:0
     inet brd scope global secondary eth0:1
     inet6 fe80::25c6:9e7:8271:b411/64 scope link
        valid_lft forever preferred_lft forever

We have two network interfaces, the first one (lo) is our localhost whose address and this only has local scope towards the device. The eth0 interface is a network interface connected by cable (ethernet), which in this example has the ip address

There are also other options for displaying network interfaces, for example using the ifconfig command. With the ip utility To configure a network interface in Linux, it is possible to do it using the following command:

ip address add dev eth0 

With this command, we add the ip address, which has a 16-bit netmask. This means that we can have 16 bits of different IP addresses for our local network, which in network terms is represented as (/ 16). We assign this ip address to the eth0 interface.

Network configuration with ifconfig

If you want to use the ifconfig command, the network configuration is done through the following command:

ifconfig eth0 netmask broadcast 

Here the assignment of the ip is for the eth0 interface, a 24-bit netmask is established (, or / 24) and the broadcast is made to the replicator or modem (gateway) located with the ip

Virtual interface configuration

In real network interfaces, each interface can store an IP address (version 4) for identification of the equipment or device, however, thanks to virtual interfaces, we can assign several interfaces within a single interface, each with its respective ip.

For the assignment of virtual addresses, we make use of the ifconfig command and indicate the network interfaces numerically as follows:

ifconfig eth0:0 
ifconfig eth0:1 

In the example above, we configure two virtual interfaces within the real eth0 interface, which respond to the name eth0:0 and eth0:1 respectively. They also have their own IP address.

Other interesting topics

We recommend you follow us and read these Linux tutorials:

Task automation in Linux with Crontab
Adding users, groups and superusers in Linux
Introduction to Git
1 0