How to configure network basics on Linux with ifconfig

Mustafa AK
Clarusway
Published in
3 min readMar 24, 2021

As a DevOps Engineer, we use mainly Linux environment and we need to know network configuration on Linux. In this article, I will show some basic Linux commands related to network configurations on my virtual Ubuntu 20.04 LTS.

In order to identify available interfaces, we use ifconfig command. You can find IPv4, IPv6, network mask, broadcast address, MAC address, and other information after executing this command.

ifconfig

In order to disable or enable our network interface, we use the below command.

sudo ifconfig <network interface name> down
sudo ifconfig <network interface name> up

if we would like to change our interface ip address, then we execute followed command. I have changed my ip address from 10.0.2.15 to 10.0.2.20 with that command.

sudo ifconfig <network interface name > <new ip adress>

We can also change our network mask address with following command. I have changed my netmask from 255.0.0.0 to 255.255.255.0 with that command.

sudo ifconfig <network interface name> netmask <netmask address>

In order to change out the maximum transmission unit (mtu), we could use the following command. I have changed this value from 1500 to 4000.

sudo ifconfig <network interface name> mtu <mtu value>

Now we will learn how to enable and disable promiscuous mode on Linux. Promiscuous mode or promisc mode is a feature that makes the ethernet card pass all traffic it received to the kernel. You can learn more about promisc mode here.

This code can enable the promisc mode.

sudo ifconfig <network interface name> promisc

Here you can disable promisc mode with that code.

sudo ifconfig <network interface name> -promisc

Finally, we will learn how to change our MAC address temporarily. A media access control address (MAC address) is a unique identifier assigned to a network interface controller (NIC) for use as a network address in communications within a network segment. You can learn about MAC here.

Normally my MAC address 08:00:27:10:53:05. But I want to change it temporarily.

sudo ifconfig <network interface name> hw ether <new MAC address>

If you would like to learn more about ifconfig command, you can visit this website.

--

--

Mustafa AK
Clarusway

DevOps Engineer @ relayr | 2 x AWS and 2 x Azure Certified Cloud Engineer | Terraform | CKA | CKAD