ipconfig Linux: Essential Commands for Network Management

Discover how to use ipconfig Linux for seamless network management and troubleshooting. Master your network settings today!

Updated: 12 Oct, 24 by Lisa P 10 Min

List of content you will read in this article:

Knowing how to control and find your IP address is a key ability in the world of Linux. Finding your IP address is a necessary step in all tasks, whether you are doing server setups, managing network configurations, or troubleshooting network issues. Technical administrators and developers can benefit from familiarizing themselves with the public and private IP address differences as well as knowing which commands to use, ifconfig for example, to modify them, thus improving security and network operations. This guide will teach you everything you need to know about IP addresses in the Linux operating system and how to use the ifconfig command to manage them.

The ifconfig command is an excellent and multi-functional device for the configuration and display of network interface parameters. Although contemporary distributions have a tendency to use tools like ip, ifconfig is still popular because it is easy to use and has good functionality, especially on older systems. It doesn't matter if you are a well-versed system administrator or a Linux novice, mastering the use of this linux command will help you in managing network interfaces.

Understanding the Syntax of the ifconfig Command in Linux

ifconfig syntax is made very clear yet it provides all the tools to control the network. The overall structure:

ifconfig [interface] [options]

  • Interface: Specify the name of the network interface you wish to configure or view. This will be a device like eth0 or wlan0.
  • Options: These are the flags or parameters that tell the interface what you want it to do (e.g., enable, disable, assign IP).

Installing Net-Tools on Linux

On newer Linux distributions, ifconfig is very seldom installed by default as it belongs to the Net-Tools package which has been replaced by the ip utility largely. Nevertheless, a significant portion of computer users are still loyal to ifconfig because of its simplicity and user-friendliness. To install it follow these commands:

sudo apt-get install net-tools

Now using ifconfig you can find and configure your network interfaces.

How to Find Your IP Address Using ifconfig?

After the Net-Tools package has been set up, just open the terminal and type:

ifconfig

This will give you the list of all the network interfaces, IP addresses, subnets, and the mask and broadcast addresses. Find the interface that is connected to the internet (it is usually either eth0 or wlan0) and your IP address will be visible next to inet.

Available Options with the ifconfig Command

ifconfig is a tool that provides the various options for managing the network. You can do the following with it:

  • To enable or disable interfaces
  • To assign or modify IP addresses
  • To set netmasks and broadcast addresses
  • To enable promiscuous mode for packet sniffing
  • To view network statistics, like transmission errors

Getting to know these options is important for the advanced network configuration and troubleshooting in the Linux systems.

It is highly important to understand the difference between public and private IP addresses when dealing with Linux networks. The public one is given by your ISP and is used to communicate with devices that are outside of your network. It is not an internet protocol address. It is a globally unique identifier that can be accessed from any corner of the planet.

On the contrary, a private IP address is one that is used only within the local network to allow communication among devices like computers, routers, and printers. Private IPs are not reachable from the Internet and these ones usually fall in the following ranges:

  • 10.0.0.0 to 10.255.255.255
  • 172.16.0.0 to 172.31.255.255
  • 192.168.0.0 to 192.168.255.255

Knowing whether the IP is a public one or a private one is easily the most important thing. Security professionals have to deal with firewall settings, VPN connection configurations, or remote access to servers.

Knowing the public IP address of a system is important for things like remote access, server hosting, or simply understanding how the system is viewed from the outside. Linux systems provide several options to easily find one's public IP.

Different Ways to Find Your Public IP in Linux

One of the most straightforward ways to track your public IP address is by using a third-party service. You could do it by curl in your terminal to an outside site, for example:

curl ifconfig.me

This will let you know what your public IP address is. Another way is to execute the dig command with OpenDNS:

dig +short myip.opendns.com @resolver1.opendns.com

These are examples of quick and effective ways to get your public IP address without having to access your router.

Your private IP address is not just a simple number but rather it is your own communication between devices on your personal local network. Either you are a file sharing user, a local server owner, or a connectivity issue troubleshooter, knowing your private IP address is a must.

Different Ways to Find Your Private IP in Linux

Your Linux device has multiple methods to tell you the private IP address. Using the command hostname -I is the easiest one.

This shows you the private IP address in no time. Another option is to use ifconfig, which will show you the detailed info of your network interfaces. This info will also include the private IP address.

The syntax of ifconfig is one of the most critical skills to acquire to master the Linux network interfaces. The typical syntax is:

ifconfig [interface] [command] [options]

To illustrate, if you want to see the settings of one specific interface such as eth0, you would input:ifconfig eth0

Exploring Linux ifconfig Command Options

Some options which prove to be useful in the instance of an ifconfig command:

  • up and down: Enable or disable an interface.
  • inet addr: Indicate or provide the interface's IP address.
  • netmask: Set or indicate the subnet mask.
  • broadcast: Determine the interface's broadcast address.
  • promisc: Enable or disable promiscuous mode, useful for packet capturing.
  • mtu: Specify the interface's Maximum Transmission Unit (MTU) size.

It is well known that ifconfig is a very powerful tool and that the best way to understand its full potential is to go through several real-life examples of the command in action.

1. View Active Network Interface Settings

To check the IP addresses of active interfaces, run ifconfig.

2. Display a Shortlist of Active Interfaces

If you want the more concise list of active interfaces, use the following:

ifconfig -a

This shows both the ones that are currently running and the ones that are shut down along with their configuration.

3. Print Verbose Output

For a more detailed examination of your network interface settings, use the -v option.

4. Show Every Network Interface Configuration

To display the interfaces including the inactive ones:

ifconfig -a

5. Get Information About a Specific Network Interface

If you want to know only the information for a certain interface, for example, eth0, use:

ifconfig eth0

This will visualize the eth0 interface with its detailed configuration.

6. Disable a Network Interface

For a temporary disabling of a networking interface, type:

sudo ifconfig eth0 down

7. Enable a Network Interface

To re-enable the interface, use:

sudo ifconfig eth0 up

8. View IP Addresses

When ifconfig command is entered without any flags, a list of active interfaces along with their corresponding IP addresses will be presented.

9. Assign an IP Address to an Interface

To be more exact in assigning a specific IP to an interface, type the command:

sudo ifconfig eth0 192.168.1.10

10. View Network Interface Masks

ifconfig command shows the subnet mask of the interface as part of the data output.

11. Assign a Netmask to an Interface

To manually assign a netmask to an interface, use the following:

sudo ifconfig eth0 netmask 255.255.255.0

12. View Broadcast Address of Interfaces

Check the broadcast address of the interface by running ifconfig.

13. Assign a New Broadcast IP to an Interface

Setting up a new broadcast address can be done with the command:

sudo ifconfig eth0 broadcast 192.168.1.255

14. Configure Multiple Network Parameters with One Command

In order to set up the IP address, netmask, and broadcast address all at once, the command is as follows:

sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255

15. Set MTU for an Interface

Setting MTU for a network interface using the command is:

sudo ifconfig eth0 mtu 1400

16. Set an Alias IP

Alias IP addresses give the opportunity to assign multiple IP addresses to one interface. To set an alias IP, use:

sudo ifconfig eth0:0 192.168.1.11

17. Enable Promiscuous Mode

Promiscuous mode is desirable for network analysis as well as packet capturing. To enable it:

sudo ifconfig eth0 promisc

18. Disable Promiscuous Mode

Disabling promiscuous mode can be accomplished with the command:

sudo ifconfig eth0 -promisc

19. View Transmission Errors

To view transmission and packet errors use the ifconfig command. This is important for the diagnosis of network problems.

A gateway is a device like a router which connects your local network to the internet or a different network. ifconfig in Linux is a utility that you can use to view and configure gateway settings. Nevertheless, the primary tool used for configuring routing in recent Linux distributions is ip. To find out the address of the default gateway you can execute the following command: ip route show

The ifconfig command is a very powerful tool for managing Linux network interfaces. Although ifconfig has largely been replaced by ip in modern distributions, it is still important to know how to use it, especially for legacy systems or simple network configurations. ifconfig is a multifunctional tool that allows you to manage your network effectively, such as displaying IP addresses, configuring netmasks, and enabling promiscuous mode.

Your IP address can be immediately viewed using the hostname -I or ifconfig  command. Your private IP addresses will be revealed with the two commands while the public IP addresses can be received via the external services like curl ifconfig.me.

One of the methods to view only your public IP address is to execute a curl ifconfig.me command or use the dig command with OpenDNS. These services show your public IP address only, without local network information.

Sure, most Linux distributions come with tools that can help you to control networks, Network Manager being one of them. The tools are simply and directly finding both public and private IP addresses without using the terminal.

For getting the IP address of a specific network interface, for example, eth0, you can type the following command: ifconfig eth0 This will present the very specific data, including the IP address assigned to that interface.

To show detailed information about each and every network interface, you can run the command: ifconfig -a This will show a list of all the interfaces, whether they are online or offline, and it will include all the configuration details such as IP addresses, netmasks, broadcast addresses, and many others.

Lisa P

Lisa P

Hello, everyone, my name is Lisa. I'm a passionate electrical engineering student with a keen interest in technology. I'm fascinated by the intersection of engineering principles and technological advancements, and I'm eager to contribute to the field by applying my knowledge and skills to solve real-world problems.