How to Use the Linux ifconfig command?

The ifconfig command is a useful tool for configuring and displaying network interfaces on Linux systems. In this blog post, we will explain how to use the ifconfig command with some examples and tips.

The ifconfig command is a useful tool for configuring and displaying network interfaces on Linux systems. In this blog post, we will explain how to use the ifconfig command with some examples and tips.

What is the ifconfig command?

The ifconfig command stands for “interface configuration”. It allows you to view and modify the settings of your network interfaces, such as IP address, netmask, broadcast address, MAC address, MTU (maximum transmission unit), and more. You can also use the ifconfig command to enable or disable a network interface, or to troubleshoot network problems.

How to use the ifconfig command?

I am doing these operations on Ubuntu 22.04. If you do not have an Ubuntu installation yet, you can look at the installation here.

To use the ifconfig command, you need to open a terminal and type:

ifconfig
ifconfig nettols ifconfig command

if you get a warning like below. First you have to install the net-tools tool. Use the code below for setup. Example setup is shown in the video.

sudo apt install net-tools

This will display information about all the network interfaces on your system. You will see something like this:

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.34  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::90a0:959c:8ca9:b312  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:fd:e2:3b  txqueuelen 1000  (Ethernet)
        RX packets 648999  bytes 920825629 (920.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 228403  bytes 19925313 (19.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 1487  bytes 177035 (177.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1487  bytes 177035 (177.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

The output shows two network interfaces: enss3 and lo. The eth0 interface is the Ethernet interface that connects to the local network. The lo interface is the loopback interface that is used for internal communication within the system.

Each interface has a set of flags that indicate its status and features. For example, UP means that the interface is active, BROADCAST means that it can send broadcast packets, RUNNING means that it has a carrier signal, and MULTICAST means that it can join multicast groups.

You can also specify a single interface name after the ifconfig command to display information about that interface only. For example:

configzone@configzone-vm:/home$ ifconfig ens33
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.34  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::90a0:959c:8ca9:b312  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:fd:e2:3b  txqueuelen 1000  (Ethernet)
        RX packets 679264  bytes 957141908 (957.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 241053  bytes 22868186 (22.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
ifconfig ens33 ifconfig command

This will show information about the eth0 interface only.

How to change the settings of a network interface?

You can use the ifconfig command with some options and arguments to change the settings of a network interface. For example, you can change the IP address of an interface by using the following syntax:

ifconfig <interface> <IP address>

For example:

ifconfig ens33 192.168.1.20
ifconfig set ip ifconfig command

This will change the IP address of the eth0 interface to 192.168.1.20.

You can also change the netmask, broadcast address, MTU size, and other settings by using different options and arguments with the ifconfig command. For example:

ifconfig eth0 netmask <netmask>

ifconfig eth0 broadcast <broadcast address>

ifconfig eth0 mtu <MTU size>

You can also combine multiple options and arguments in one command to change multiple settings at once. For example:

ifconfig eth0 <IP address> netmask <netmask> broadcast <broadcast address>

Muscal

Leave a Reply

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

Next Post

How to install Firefox on Ubuntu step by step

Mon Apr 10 , 2023
Firefox is a popular web browser that is available for various operating systems, including Ubuntu Linux. Firefox is a popular web browser. install Firefox on Ubuntu step by step.
Firefox Ubuntu

You May Like