Tecmint: Linux Howtos, Tutorials & Guides

15 Useful “ifconfig” Commands to Configure Network Interface in Linux

ifconfig in short “ interface configuration ” utility for system/network administration in Unix/Linux operating systems to configure, manage, and query network interface parameters via command-line interface or in a system configuration scripts.

The “ ifconfig ” command is used for displaying current network configuration information, setting up an ip address, netmask, or broadcast address to a network interface, creating an alias for the network interface, setting up hardware address, and enabling or disabling network interfaces.

You might also like:

  • 22 Linux Networking Commands for Sysadmin
  • 15 Useful Performance and Network Monitoring Tools for Linux
  • 11 Best IP Address Management Tools for Linux Network
  • 13 Linux Network Configuration and Troubleshooting Commands

This article covers 15 useful “ ifconfig ” commands with their practical examples, which might be very helpful to you in managing and configuring network interfaces in Linux systems.

1. List Network Interfaces in Linux

The “ ifconfig ” command with no arguments will display all the active network interface configuration details that includes their assigned IP addresses, netmasks, and other relevant information.

Sample Output:

2. Display Information on All Network Interfaces

The following ifconfig command with the -a argument will display information on all active or inactive network interfaces on the server. It displays the results for eth0 , lo , sit0, and tun0 .

3. View Network Settings of Specific Interface

Using interface name ( eth0 ) as an argument with the “ ifconfig ” command will display details of the specific network interface.

4. How to Enable a Network Interface

The “ up ” or “ ifup ” flag with interface name ( eth0 ) activates a network interface if it is not inactive state and allows to send and receive information.

For example, “ ifconfig eth0 up ” or “ ifup eth0 ” will activate the eth0 interface.

5. How to Disable a Network Interface

The “ down ” or “ ifdown ” flag with interface name ( eth0 ) deactivates the specified network interface. For example, the “ ifconfig eth0 down ” or “ ifdown eth0 ” command deactivates the eth0 interface if it is in an inactive state.

6. How to Assign an IP Address to Network Interface

To assign an IP address to a specific interface, use the following command with an interface name ( eth0 ) and ip address that you want to set. For example, “ ifconfig eth0 172.16.25.125 ” will set the IP address to interface eth0 .

7. How to Assign a Netmask to Network Interface

Using the “ ifconfig ” command with the “ netmask ” argument and interface name as ( eth0 ) allows you to define a netmask to a given interface. For example, “ ifconfig eth0 netmask 255.255.255.224 ” will set the network mask to a given interface eth0 .

8. How to Assign a Broadcast to Network Interface

Using the “ broadcast ” argument with an interface name will set the broadcast address for the given interface. For example, the “ ifconfig eth0 broadcast 172.16.25.63 ” command sets the broadcast address to an interface eth0 .

9. How to Assign an IP, Netmask, and Broadcast to Network Interface

To assign an IP address, Netmask address, and Broadcast address all at once using the “ ifconfig ” command with all arguments as given below.

10. How to Change MTU for a Network Interface

The “ mtu ” argument sets the maximum transmission unit to an interface. The MTU allows you to set the limit size of packets that are transmitted on an interface. The MTU is able to handle a maximum number of octets to an interface in one single transaction.

For example, “ ifconfig eth0 mtu 1000 ” will set the maximum transmission unit to a given set (i.e. 1000 ). Not all network interfaces support MTU settings.

11. How to Enable Promiscuous Mode

What happens in normal mode, is when a packet is received by a network card, it verifies that it belongs to itself. If not, it drops the packet normally, but in the promiscuous mode is used to accept all the packets that flow through the network card.

Today’s network tools use the promiscuous mode to capture and analyze the packets that flow through the network interface. To set the promiscuous mode, use the following command.

12. How to Disable Promiscuous Mode

To disable promiscuous mode, use the “ -promisc ” switch that drops back the network interface to normal mode.

13. How to Add New Alias to Network Interface

The ifconfig utility allows you to configure additional network interfaces using the alias feature. To add the alias network interface of eth0 , use the following command. Please note that the alias network address is in the same subnet mask. For example, if your eth0 network ip address is 172.16.25.125 , then the alias ip address must be 172.16.25.127 .

Next, verify the newly created alias network interface address, by using the “ ifconfig eth0:0 ” command.

14. How to Remove Alias to Network Interface

If you no longer required an alias network interface or you incorrectly configured it, you can remove it by using the following command.

15. How to Change the MAC address of Network Interface

To change the MAC ( Media Access Control ) address of an eth0 network interface, use the following command with the argument “ hw ether “. For example, see below.

These are the most useful commands for configuring network interfaces in Linux , for more information and usage of the ifconfig command use the manpages like “ man ifconfig ” at the terminal. Check out some other networking utilities below.

Other Networking Utilities

  • nmcli – a command-line client that is used to control NetworkManager and report network information.
  • Tcmpdump – is a command-line packet capture and analyzer tool for monitoring network traffic.
  • Netstat – is an open-source command-line network monitoring tool that monitors incoming and outgoing network packet traffic.
  • ss (socket statistics) – a tool that prints network socket-related information on a Linux system.
  • Wireshark – is an open-source network protocol analyzer that is used to troubleshoot network-related issues.
  • Munin – is a web-based network and system monitoring application that is used to display results in graphs using rrdtool.
  • Cacti – is a complete web-based monitoring and graphing application for network monitoring.

To get more information and options for any of the above tools, see the man pages by entering “ man toolname ” at the command prompt. For example, to get the information for the “ netstat” tool, use the command “ man netstat “.

Previous article:

Next article:

Photo of author

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Related Posts

Set GRUB Password

How to Set GRUB2 Password in RHEL-based Systems

Add Multiple IP Addresses to NIC

How to Assign Multiple IPs to a Single Network Interface in Linux

Find Last Executed Commands in Linux

The Power of Linux “History Command” in Bash Shell

Ncdu - Disk Usage Analyzer

Ncdu – A Powerful NCurses-Based Disk Usage Analyzer for Linux

Append Text To File in Linux

How to Add Text to Existing Files in Linux

Check Running Process Time in Linux

How to Check How Long a Process Has Been Running in Linux

27 thoughts on “15 Useful “ifconfig” Commands to Configure Network Interface in Linux”

Like everywhere, the following syntax is not described (even on the man page):

Nowhere I saw such a case, address may be multiple addresses … WHY?

and in man ssh such usage is made !!

ifconfig has mostly been succeeded by the ‘IP’ command. Also ‘ss’ replaces ‘netstat’. Perhaps it is time to revisit the old lore and make some updates ;)

Guys ifconfig command is outdated please update this page.

lmao sry for being salty, I found the command.

Hi friends,

Why gw is set with ifconfig command?

I am a not Linux fan at all and usually don’t share any opinion but the content of all topics is great as well as good and concisely put.

Thank you for every tutorial you publish, really very helpful for learning.

Please go on. Thanks again

wow !! really i could never expect these type of content … really u doing great job .. and thanks alot .

thank you for all points

So how do we set the gateway ?

Use the following route command to add default gateway in Linux.

thanks guys for all of your cooperation!!!!!!!!!!!!!!!!!

What is netmask and broadcast, And what is use of this.

A netmask is a 32-bit mask used to separate an IP address into subnets and specify the network’s available hosts, whereas broadcasting refers to transmitting a packet that will be received by each device in the network.

The network commands defines numerous tools, which can be helpful when networking with further computer systems inside both the network & cross ways the Internet, attaining additional detail about further computer systems.

Can you tell me how to presist ifconfig changes after reboot? I am trying to change broadcast and netmask with ifconfig. It changes successfully but after reboot it revert back to previous settings.

Thanks in Advance, Nikkishah

@Nikki, How you changing the network settings? directly on the command line? if yes, then settings will be for temporary only. Better add the settings in ifcfg file under network-scripts directory, if you are using Centos distro..

I have two interfaces and after ifconfig command, two interfaces show same inet address (this probably i guess I made forwarding command in iptables in firewall ), and interrupt shows read “Interrupt” as shown in example above. I dont know why interrupt is indicated and also I could connect internet. I suspect the fox browser contaminated by some hacks . What to do now, Do I need reinstall fox.

how about editing /etc/sysconfig/network-scripts/***interface-name***

I can’t reply to some emails because of an IPconfig error message and have to copy the email address into a compose document

in my iptables (centos 5) i use ! command

after install new version of centos6.3 i get error that is deprecated command

plz help me whats is instead this

Download Your Free eBook NOW – A Newbie’s Getting Started Guide to Linux I can’t download this, as it asking telephone number belongs to US to download the book, what ever number i give its shows error

Dear Sneaha,

Sorry for trouble, we will look into this issue and fix it soon.

Hi, How to know which is primary interface, if more than one interface is configured?

Hasn’t ifconfig been deprecated for awhile now?

It has, in favor of the “ip” command.

yes ‘ifconfig (net-tools)’ has been deprecated for a while now.. There is the drop-in replacement ‘iproute2’.

however, many systems still have ‘ifconfig’, it is still used by many folks even though ‘ip’ is much more powerful as it nicely manages the networking tasks. It has the functionality of the tools like ‘ifconfig’, ‘iptunel’, ‘route’ etc…

Got something to say? Join the discussion. Cancel reply

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Save my name, email, and website in this browser for the next time I comment.

FOSS Linux

@2023 - All Right Reserved.

How to use ifconfig command in Linux

The ifconfig command in linux is a powerful tool for network interface configuration and management. this guide provides an in-depth look at ifconfig, including how to use it to set ip addresses, enable/disable interfaces, and troubleshoot network issues, complete with practical examples..

ifconfig command linux

I n the dive­rse world of Linux networking tools, the “ifconfig” command stands out as a classic and re­liable tool, despite more­ comprehensive alte­rnatives like the “ip” command gaining popularity. Many use­rs continue using ifconfig due to its simplicity and ease­ of use. This guide will revisit the­ essential functions of ifconfig, as well as provide­ a cheat sheet, comparisons, and usage­ scenarios.

Whether trouble­shooting network configurations or wanting to view a system’s ne­tworking setup, ifconfig remains a reliable­ and familiar tool in the Linux community. By exploring its capabilities, we­ can appreciate its legacy while­ also gaining practical knowledge in managing network comple­xities. This guide will provide both nostalgia and practical e­xpertise using ifconfig.

ifconfig command in Linux

ifconfig , short for “interface configuration,” is a traditional command-line utility in Unix-like operating systems that allows users to configure, manage, and query network interface parameters from the command line. While it’s been somewhat overshadowed by the more modern ip command, ifconfig remains a popular and beloved tool for many due to its simplicity and ease of use.

Basic usage

At its core, ifconfig can be used without any options to display the current network configuration for all active interfaces. Here’s a typical example from a Ubuntu terminal:

In this output, you can see details about the eth0 interface, which is a typical Ethernet connection, and the lo interface, which is the loopback interface.

Configuring network interfaces

One of the primary uses of ifconfig is to configure network interfaces. Let’s say you want to assign a static IP address to an interface (eth0, in this case). You would use a command like this:

This command sets the IP address of eth0 to 192.168.1.10 and the netmask to 255.255.255.0 . Remember, you’ll need superuser privileges to make changes to network configurations, hence the sudo .

Enabling and disabling network interfaces

To disable an interface, you can run:

And to bring it back up:

Simple, right? That’s what I love about ifconfig . It doesn’t require memorizing complex syntax for performing basic network operations.

  • Top 10 Linux performance commands for system administrators
  • Ubuntu vs. Red Hat Linux: An in-depth comparison
  • systemd vs. init: Decoding the Linux boot process

Checking the MAC address

Finding the MAC address of your network interface is as simple as running ifconfig without any options. The MAC address is displayed as part of the standard output, listed under ether . Here’s the snippet from the previous example:

Advanced configuration: Adding and removing aliases

A lesser-known feature of ifconfig is its ability to manage multiple IP addresses on a single network interface through the use of aliases. This can be particularly useful for hosting multiple services on a single server. Here’s how you can add an IP address as an alias to an existing interface (eth0, in this instance):

$ sudo ifconfig eth0:0 192.168.1.11 netmask 255.255.255.0 This command assigns the IP address 192.168.1.11 to the alias eth0:0 . To remove this alias, simply bring it down:

Monitoring network traffic

While ifconfig is primarily known for configuring network interfaces, it also provides some basic statistics that can be useful for monitoring network traffic. As shown in the basic usage example, ifconfig displays information about the number of transmitted and received packets, errors, and more.

To get a more detailed view, you could continually monitor these statistics and observe changes over time. However, for in-depth traffic analysis, tools like iftop or ip -s link are more appropriate.

Troubleshooting network issues

ifconfig is pretty much your go-to buddy when it comes to sorting out network hiccups. Think you’ve got an issue with your network link? ifconfig lets you peek at your network interfaces’ status to see what’s up. Noticed an interface that’s taking an unexpected nap? A quick nudge with ifconfig can wake it right up. And if you’re tangled in some network configuration snarls, ifconfig is your handy toolkit for tweaking those settings back into shape.

Pro tip: Mash up ifconfig with buddies like ping or traceroute, and you’ve got yourself a powerful combo to track down and nail those pesky network gremlins.

The move towards ip

So, ifconfig has been riding into the sunset for a while now, with the Linux crowd leaning more towards the ip command. Why? Simply put, ip brings a lot more to the table, meshing better with the Linux Networking Stack and offering a beefier set of tools for managing the network’s ins and outs.

But, hey, change isn’t always a walk in the park. Moving from the comfort zone of ifconfig to the vast landscapes of ip can feel like learning to bike all over again, thanks to its intricate syntax. For those of us who’ve spent years in a committed relationship with ifconfig, it’s not just a tool; it’s an old friend. Yet, embracing ip opens up a whole new world of network management prowess—think of it as upgrading to a high-performance bike. Yes, there’s a bit of a learning curve, but the places you’ll go and the speed you’ll get there? Totally worth the effort.

ifconfig command cheat sheet

This cheat sheet covers a variety of basic ifconfig commands for managing network interfaces on Linux systems.

Let’s walk through a real-world example where ifconfig can be extremely useful: changing the IP address of a network interface on a Ubuntu server to configure a static IP, and then verifying the change.

Practical example – setting up local server

Imagine you’re setting up a local web server that requires a static IP address to ensure it’s consistently accessible at the same address. We’ll use ifconfig to assign a static IP address to the eth0 network interface.

Step 1: Check current network interface configuration

First, let’s check the current configuration of our network interfaces.

You might see output similar to this for eth0 :

Step 2: Assign a static IP address

Assuming you’ve agreed on using 192.168.1.150 as the static IP for the server, and the network mask is 255.255.255.0 , the command would be:

Step 3: Verify the new configuration

To ensure the IP address has been successfully assigned, run ifconfig again:

Look for the inet line, which should now reflect the new IP address:

Step 4: Testing the configuration

Finally, it’s a good practice to test the new configuration. You can ping the gateway of your network (usually the router’s IP, say 192.168.1.1 ) to ensure connectivity:

If the ping is successful, your server is correctly configured with its new static IP and can communicate with other devices on the network.

Final thoughts

Wrapping up our article with ifconfig , it’s clear this old-timer has still got it. Its mix of no-fuss functionality and handy-dandy utility means it’s hanging in there, even as the shiny new ip command struts its stuff. Our deep dive—from the ABCs to a nifty cheat sheet—has painted ifconfig as the trusty command for going through network setups and solving issues on the fly.

You may also like

How to find the largest directories in linux, how to manipulate and convert epoch time in..., how to use curl command in linux: from..., how to use the chown command in linux, how to add a user to a group..., how to remove a file or directory in..., leave a comment cancel reply.

Save my name, email, and website in this browser for the next time I comment.

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.

FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

MORE FROM US

  • Ubuntu (311)
  • Downloads (257)
  • Learn Linux (254)
  • Beginner's Guide (178)
  • Terminal Tuts (168)
  • Featured (124)
  • Server (98)
  • Linux Mint (98)
  • Fedora (93)
  • Privacy Policy
  • Terms of Use

A PART OF VIBRANT LEAF MEDIA COMPANY.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.

  • Beginner’s Guide
  • Terminal Tuts
  • Learn Linux

404 Not found

Computer Hope

Linux ifconfig command

On some Unix-like operating systems, ifconfig is used to configure , or view the configuration of, a network interface .

This page covers the GNU / Linux version of ifconfig .

On modern Linux systems, the ip command has replaced ifconfig .

Description

What about dhcp, technical description, related commands.

  • Linux commands help

ifconfig stands for "interface configuration." It is used to view and change the configuration of the network interfaces on your system.

Running the ifconfig command with no arguments, like this:

...displays information about all network interfaces currently in operation. The output resembles the following:

Here, eth0 , lo and wlan0 are the names of the active network interfaces on the system.

  • eth0 is the first Ethernet interface. (Additional Ethernet interfaces would be named eth1 , eth2 , etc.) This type of interface is usually a NIC connected to the network by a category 5 cable.
  • lo is the loopback interface. This is a special network interface that the system uses to communicate with itself.
  • wlan0 is the name of the first wireless network interface on the system. Additional wireless interfaces would be named wlan1 , wlan2 , etc.

These are the traditional naming conventions for network interfaces under Linux; other operating systems may have different names. For instance, under many BSD operating systems, Ethernet interfaces are named em0 , em1 , etc. Check your configuration, or consult your documentation, to determine the exact names of your interfaces.

Viewing the configuration of all interfaces

If you'd like to view the configuration of all network interfaces on the system (not just the ones that are currently active), you can specify the -a option, like this:

This produces output similar to running ifconfig , but if there are any inactive interfaces on the system, their configuration is also shown.

Viewing the configuration of a specific interface

To view the configuration of a specific interface, specify its name as an option. For instance,

...displays the configuration of device eth0 only.

Enabling and disabling an interface

When a network interface is active, it can send and receive data; when it is inactive, it is not able to transmit or receive. You can use ifconfig to change the status of a network interface from inactive to active, or vice versa.

To enable an inactive interface, provide ifconfig with the interface name followed by the keyword up .

Enabling or disabling a device requires superuser permissions, so you either have to be logged in as root , or prefix your command with sudo to run it with superuser privileges.

For instance, if network interface eth1 is inactive, you can activate it with the command:

Similarly, you can disable an active network interface using the down keyword. For instance, to disable the wireless network interface wlan0 , use the command:

Configuring an interface

ifconfig can be used at the command line to configure (or re-configure) a network interface. This is often unnecessary since this configuration is often handled by a script when you boot the system. If you'd like to do so manually, you need superuser privileges, so we'll use sudo again when running these commands.

To assign a static IP address to an interface, specify the interface name and the IP address. For example, to assign the IP address 69.72.169.1 to the interface wlan0 , use the command:

To assign a network mask to an interface, use the keyword netmask and the netmask address. For instance, to configure the interface eth1 to use a network mask of 255.255.255.0 , the command would be:

To assign a broadcast address to an interface, use the keyword broadcast and the broadcast address. For instance, to configure the interface wlan1 to use a broadcast address of 172.16.25.98 , the command would be:

These configurations can combined in a single command. For instance, to configure interface eth0 to use the static IP address 192.168.2.5 , the network mask 255.255.255.0 , and the broadcast address 192.168.2.7 , the command would be:

These are the most commonly-used configuration options for ifconfig . A complete list is provided below.

ifconfig can only assign a static IP address to a network interface. To assign a dynamic IP address using DHCP , use the dhclient command.

ifconfig is used to configure the system's kernel -resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging , or when system tuning is needed.

If no arguments are given, ifconfig displays the status of the system's active interfaces.

If a single interface argument is given, it displays the status of the given interface only.

If a single -a argument is given, it displays the status of all interfaces, even those that are "down" (inactive).

In all other cases, ifconfig configures an interface according to the options provided.

About address families

If the first argument after the interface name is recognized as the name of a supported address family, that address family is used for decoding and displaying all protocol addresses. Currently supported address families include, inet ( TCP/IP ; this is the default), inet6 ( IPv6 ), ax25 (AMPR Packet Radio), ddp ( Appletalk Phase 2), ipx ( Novell IPX ) and netrom (AMPR Packet Radio).

Running ifconfig with no options displays the configuration of all active interfaces.

Displays the configuration of all interfaces, both active and inactive.

View the network settings on the interface eth0 , which (under Linux) is the first Ethernet adapter installed in the system.

Activate the network interface eth1 .

Deactivate the network interface wlan0 .

Configure the network interface wlan1 to use the static IP address 122.140.201.66 .

Configure the network interface wlan0 to use the network mask 255.255.255.0 .

Configure eth0 to use the static IP address 192.168.1.102 using the network mask 255.255.255.0 , and the broadcast address 192.168.1.255 .

arp — Manipulate the system ARP cache. dhclient — Communicate with a DHCP server to obtain a dynamic IP address . ifup/ifdown — Enable/Disable a network interface. ifquery — Parse information about a network interface. ip — Display and manipulate information about routing, devices, policy routing and tunnels. iwconfig — Configure a wireless network interface. ping — Send ICMP ECHO_REQUEST packets to network hosts. netstat — Print information about network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. route — Display and manipulate the IP routing table.

  • Articles Automation Career Cloud Containers Kubernetes Linux Programming Security

Linux networking: ifconfig versus ip

%t min read | by Tyler Carrigan (Editorial Team, Red Hat)

ifconfig vs ip

What was the first Linux networking command that you learned? If I were a betting man, I would wager that many of you (like myself) learned how to look at your IP address and ethernet configurations. I would also wager that an overwhelming majority of Linux users first learned to do so via the ifconfig command.

Interface Configuration, a.k.a. ifconfig , has to be one of the most used Linux commands of all time, and it's pretty plain to see why. It's easy to remember (unless you are coming from a Windows environment), and it displays most, if not all, of the necessary networking information for a huge number of use cases.

On the other hand, we have the ip command suite. This command-line tools package is the new kid on the block, relatively speaking, and has been chosen as the way forward by the bleeding edge of Linux users. With added functionality and a steadily growing user base, the ip command is a serious contender for your muscle memory or aliases.

So let's take a look at these two commands to see what is on the ip command suite offers.

The sure thing

You know your favorite ball cap? The one that has the sweat stains inside the headliner, but throwing it on just feels right? That's ifconfig . It's safe, it's familiar, and you feel comfortable using it. The ifconfig command still has a lot to offer its users. Whether its displaying network settings, configuring an IP address or netmask, creating aliases for interfaces, or setting MAC address, ifconfig can handle it. Let's take a look at how to use ifconfig to accomplish some more common tasks you may find yourself working on completing.

Displaying current network settings

This is the most basic and overused form of the ifconfig command. Chances are, you are running this to get information about a particular interface, and while this works, it will probably over-deliver. Let's look at the syntax and output and see where we could improve our I/O.

As you can see, there is a lot of information to sift through here. ifconfig , devoid of any arguments or options, will list all active interfaces with detail. So how can we narrow it down to exactly what we want? Many times you just want to look at a specific interface.

Display entries for specific interface

To view details for a specific interface, use the standard ifconfig command followed by the interface name. For example:

Enabling and disabling an interface

With the ifconfig command, you can do far more than just view configurations. Let's take a look at how to enable and disable an interface.

To enable an interface, you have two options for syntax:

The same goes for disabling an interface. Only instead of up we use down , as seen here:

In this line of work, it really doesn't get much easier than that.

Assigning an IP address to an interface

To assign an IP address to a given interface, you use the following syntax:

For example:

Assigning a netmask to an interface

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

It should look like this:

Set MTU for an interface

The MTU or Maximum Transmission Unit is a very important figure to pay attention to during troubleshooting. This value allows you to limit the size of packets sent over the specific interface. I once worked a data replication failure for over three weeks before figuring out that the MTU was too large for the replication interface. Fun times *insert eye roll here*. I say this to make a point. Not every network interface can support jumbo packets. Be sure that the set MTU is supported for your interface. To set the MTU:

There is a lot more that ifconfig can do; however, in the interest of brevity, I am going to move along. If you want more information on ifconfig , check out the man page or your friendly neighborhood search engine.

[ Getting started with networking? Check out the Linux networking cheat sheet . ]

What's trending?

The ip command is the future of network config commands. ifconfig has been officially deprecated for the ip suite, so while many of us are still using the old ways, it is time to put those habits to rest and move on with the world.

Displaying entries

Since there is no "without options" variant of the ip command, let's look at how to display IP addresses associated with interfaces.

You will notice that this presents much of the same information as the base ifconfig command.

Adding a new address

To add an IP address to an existing interface, use the following:

The dev flag is used before designating which device or interface that the IP address is being set on.

Removing an address

To remove an IP address from an interface, use the following:

Enable and disable an interface

Much like the ifconfig command, you can also cycle an interface on/off using the ip command. To enable an interface, use the following:

to disable:

View the routing table

One of the best things you can use while troubleshooting is to view routing information. To do this, use the following:

You can also add and remove static routes from the routing table.

To add a static route, we use the following:

To remove a static route, we use the following:

Note that these are not persistent, and you must take additional steps to ensure that the routes created actually survive a reboot. To create the persistent route, we need to create an entry in /etc/sysconfig/network-scripts/route-eth0 (substitute eth0 with whatever interface the route is created on). Something like this:

Over before it began

This article is not so much a fight between the two as it is an exploration of old and new. The decision has already been made, as  ifconfig is being deprecated. The ip command suite is the way forward. However, just because something is new doesn't mean it is superior for every purpose. At the same time, however, "we've always done it this way" is not an excuse to stop improving. What are your thoughts? My honest takeaway is that ifconfig meets most of my needs (at this point in my career). However, the ip command is a more powerful tool and will be a staple for networking experts for years to come.

[ Want more for your network? Download a free ebook on network automation with Ansible. ]

Author’s photo

Tyler Carrigan

Tyler is the Sr. Community Manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. More about me

Try Red Hat Enterprise Linux

Download it at no charge from the red hat developer program., related content.

A blue cable plugged into a green Raspberry Pi

LinuxSimply

Home > The “ifconfig” Command in Linux [6+ Practical Examples]

The “ifconfig” Command in Linux [6+ Practical Examples]

Anonnya Ghosh

The ifconfig command in Linux stands for “ Interface Configuration ”. It configures the necessary kernel-resident network interfaces at the system boot. Users can also apply this command to configure interfaces as per their needs. In this article, I will illustrate the basic usage of the ifconfig command in Linux .

A. Description

The ifconfig command in Linux is used to configure a network interface. If no argument is passed it lists all the active interfaces on a system.

The syntax of the ifconfig command in Linux is really simple as it contains the command itself and single or multiple options. The syntax is given below.

Many useful options are available for the ifconfig command. I have listed some of the most used ones here. However, to learn more about the ifconfig command you can always check the man page .

Useful Options

  • -a: Displays all available interfaces including down ones.
  • address: Indicates the IP address to be assigned to an interface.
  • -s: Displays a short list of active interfaces.
  • -v: Displays verbose output for error conditions.
  • interface: Indicates specified interface.
  • up: Activates an interface.
  • down: Shuts down an interface.
  • mtu N: Sets the Maximum Transfer Unit (MTU) of an interface.
  • [-]arp: Enables or disables the promiscuous mode of the interface.
  • [-]promisc: Enables or disables the promiscuous mode of the interface.
  • add addr/prefixlen: Adds an IPv6 address to an interface.
  • del addr/prefixlen: Removes an IPv6 address from an interface.

Installing the “ifconfig” Command in Linux

The ifconfig command may not be readily installed on your machine. You can find out whether you have it on your system or not by typing the command ifconfig itself.

Showing error message upon not finding the ifconfig command in linux.

In this case, don’t be overwhelmed. The ifconfig command comes with the net-tools package. You can install the net-tools package within a minute by following the instructions below.

Steps to Follow >

➊ At first, open the Ubuntu Terminal

➋ Type the following in your command prompt:

➌ Type your password

➍ Now, press ENTER

Output >

Installing ifconfig command in linux.

Practical Examples of the “ifconfig” Command in Linux

The ifconfig command in Linux is a command that enables users to configure network interfaces. Some of the most useful applications of the ifconfig command have been illustrated below.

Example 1: Displaying Information on All Network Interfaces Available on the System

You can display information on all networks connected to your system using the ifconfig command in Linux . You will need to use the option – a to get this output. In this example, I will display all the interfaces available on my system. Follow the instructions below to do the same.

➊ At first, open the Ubuntu Terminal .

➋ Type the following command in the command prompt:

➌ Now, press the ENTER button.

Displaying Information on All Network Interfaces Available on the System.

Similar Readings

  • The “ftp” Command in Linux [14 Practical Examples]
  • The “host” Command in Linux [10 Practical Examples]
  • The “scp” Command in Linux [4 Practical Examples]
  • The “sftp” Command in Linux [6 Practical Examples]

Example 2: Displaying a Short  List of Active Network Interfaces Using the “ifconfig” Command in Linux

You can display a short list of all the active network interfaces using the ifconfig in Linux with the option -s . In this example, I will list the interfaces on my system. You can do the same by following the steps below.

➊ Open the Ubuntu Terminal .

➌ Press the ENTER button.

Displaying a Short  List of Active Network Interfaces.

Example 3: Assigning IP Address to an Interface Using the “ifconfig” Command in Linux

You can add a new IP address to your available network device using the ifconfig command in Linux . You must run the command as the superuser using the sudo keyword to achieve this task. The IP address needs to be mentioned after the specified interface. In this example, I will add the address 192.168.242.240 to the ens33 network on my system. You can do so by following the process below:

➊ At first, launch the Ubuntu Terminal .

➌ Now, hit the ENTER button.

Assigning IP Address to an Interface Using the ifconfig Command in Linux.

Example 4: Altering Status of Network Interfaces Using the “ifconfig” Command in Linux

You can alter the network interface status from your terminal using the ifconfig command in Linux . You can bring an interface up or down by running commands as a superuser using the sudo command. To do so, you will need to use the options up or down after a specific interface name. Follow the below examples to change the statuses separately.

Case A: Bringing an Interface Up Using the “ifconfig” Command in Linux

To bring an interface up follow the given steps.

➍ To view the updated status write the following command:

➎ Again, press ENTER .

Bringing an Interface Up Using the ifconfig Command in Linux.

Case B: Bringing an Interface Down Using the “ifconfig” Command in Linux

To bring an interface down follow the given steps.

➊ At first open the Ubuntu Terminal .

Bringing an Interface Down Using the ifconfig Command in Linux.

Example 5: Setting MTU size Using the “ifconfig” Command in Linux

You can set the Maximum Transfer Unit of an interface using the mtu option with the ifconfig command in Linux . In this example, I will set the transfer unit of the “ ens33 ” interface to 500 . To do the same, you can go through the following steps.

➌ Hit ENTER .

Setting MTU size Using the fconfig Command in Linux.

  • The “ dig” Command in Linux [10 Practical Examples]
  • The “hostname” Command in Linux [12 Practical Examples]
  • The “ip” Command in Linux [9+ Practical Examples]
  • The “iptables” Command in Linux [6 Practical Examples]

Example 6: Enabling/Disabling Promiscuous Mode Using the “ifconfig” Command in Linux

You can enable or disable the promiscuous mode of an interface using the ifconfig command in Linux . To do so you have to use the promisc option with or without the “ – ” to enable or disable the mode. Follow the below examples to achieve the two different modes.

Case A: Enabling Promiscuous Mode Using the “ifconfig” Command in Linux

To enable the promiscuous mode of an interface, follow the given steps.

➌ Hit ENTER button.

Enabling Promiscuous Mode Using the ifconfig Command in Linux.

Case B: Disabling Promiscuous Mode Using the “ifconfig” Command in Linux

To disable the promiscuous mode of an interface follow the given steps.

➊ At first, go to the Ubuntu Terminal .

➌ Press ENTER .

Disabling Promiscuous Mode Using the ifconfig Command in Linux.

This article presents the most frequent uses of the ifconfig command in Linux . Exercising the provided hands-on examples, you will be able to configure network interfaces along with viewing their information. I hope the demonstrations aid your experience in the command line and help you become a power user of Linux .

  • The “netstat” Command in Linux [22 Practical Examples]
  • The “nslookup” Command in Linux [12 Practical Examples]
  • The “ufw” Command in Linux [12+ Practical Examples]
  • The “ssh” Command in Linux [18 Practical Examples]
  • The “traceroute” Command in Linux [13 Practical Examples]
  • The “rsync” Command in Linux [10 Practical Examples]

icon linux

Anonnya Ghosh

Hello there! I am Anonnya Ghosh, a Computer Science and Engineering graduate from Ahsanullah University of Science and Technology (AUST). Currently, I am working as a Linux Content Developer Executive at SOFTEKO. The strong bond between Linux and cybersecurity drives me to explore this world of open-source architecture. I aspire to learn new things further and contribute to the field of CS with my experience. Read Full Bio

Leave a Comment Cancel reply

Save my name, email, and website in this browser for the next time I comment.

PrepBytes Blog

ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING

Sign in to your account

Forgot your password?

Login via OTP

We will send you an one time password on your mobile number

An OTP has been sent to your mobile number please verify it below

Register with PrepBytes

Ifconfig command in linux with examples.

' src=

Last Updated on November 24, 2023 by Abhishek Sharma

assign ip ifconfig

This comprehensive guide aims to delve into the ‘ifconfig’ command, covering its functionalities, practical usage scenarios, and a variety of examples to assist users in understanding its versatility in Linux environments.

What is ‘ifconfig’ in Linux?

‘ifconfig’ is a command-line tool primarily used to configure, view, and troubleshoot network interfaces on Linux systems. It provides a comprehensive display of network-related information, including IP addresses, MAC addresses, netmasks, and more.

Syntax of ifconfig Command in Linux:

Basic usage: displaying network interface information.

To view information about all active network interfaces on your system, simply open the terminal and type:

This command will output details for all active interfaces, including their names, IP addresses, MAC addresses, and additional configuration parameters.

Example 1: Displaying Specific Interface Information

Suppose you want detailed information about a particular interface, say ‘eth0’. You can use the following command:

This command will specifically display the details related to the ‘eth0’ network interface, providing information such as IP address, netmask, broadcast address, and more.

Configuring Network Interfaces ‘ifconfig’ also enables users to configure network interfaces with specific parameters. For instance, to assign an IP address to a network interface, you can use the following command:

Replace and with the IP address and netmask you want to assign to the ‘eth0’ interface, respectively. Please note that using ‘sudo’ might be necessary to execute this command with administrative privileges.

Example 2: Assigning an IP Address Let’s say you want to assign the IP address ‘192.168.1.10’ with a netmask of ‘255.255.255.0’ to the ‘eth0’ interface. You can accomplish this by executing:

Conclusion: The ‘ifconfig’ command remains a fundamental tool for managing network interfaces in Linux, providing users with the ability to retrieve vital network information and configure interfaces as needed. While ‘ifconfig’ has been widely used for years, it’s important to note that newer versions of Linux distributions are transitioning towards the ‘ip’ command for networking tasks. Nevertheless, understanding ‘ifconfig’ is still valuable for maintaining and troubleshooting networks, making it an essential command-line utility for Linux users.

By exploring the various functionalities and examples provided in this guide, users can leverage ‘ifconfig’ effectively, gaining better control over their network configurations within the Linux environment.

FAQ related to ifconfig command in linux with examples

Here are some Related to ifconfig command in linux with examples.

1. What is the ‘ifconfig’ command in Linux? ‘ifconfig’ is a command-line utility used in Unix-like operating systems, including Linux, to configure and display information about network interfaces on a system. It allows users to view, configure, and manipulate network interface parameters such as IP addresses, netmasks, broadcast addresses, and more.

2. How do I use ‘ifconfig’ to display network interface information? To display information about all active network interfaces, simply type ‘ifconfig’ in the terminal without any arguments. This command will output details such as interface names, IP addresses, MAC addresses, and other relevant network settings.

3. How can I configure a network interface using ‘ifconfig’? To configure a network interface with specific parameters, such as setting an IP address or changing the netmask, you can use commands like ‘ifconfig eth0 netmask ‘. However, note that ‘ifconfig’ is being gradually deprecated in favor of the ‘ip’ command, especially in newer Linux distributions.

Leave a Reply Cancel reply

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

Save my name, email, and website in this browser for the next time I comment.

  • Linked List
  • Segment Tree
  • Backtracking
  • Dynamic Programming
  • Greedy Algorithm
  • Operating System
  • Company Placement
  • Interview Tips
  • General Interview Questions
  • Data Structure
  • Other Topics
  • Computational Geometry
  • Game Theory

Related Post

Find command in linux with examples, awk command in unix/linux with examples, grep command in unix linux, ps command in linux with examples, curl command in linux with examples, tail command linux examples.

Logo

15 Useful “ifconfig” Commands to Configure Network Interface in Linux - DesignLinux

ifconfig in short “ interface configuration ” utility for system/network administration in Unix/Linux operating systems to configure, manage and query network interface parameters via command-line interface or in a system configuration scripts.

[ You might also like: 22 Linux Networking Commands for Sysadmin ]

The “ ifconfig ” command is used for displaying current network configuration information, setting up an ip address, netmask, or broadcast address to a network interface, creating an alias for the network interface, setting up hardware address, and enable or disable network interfaces.

Ifconfig Command Examples

This article covers “ 15 Useful “ifconfig” Commands ” with their practical examples, which might be very helpful to you in managing and configuring network interfaces in Linux systems.

Update : The networking command ifconfig is deprecated and replaced by the ip command (Learn 10 Examples of IP Command) in most Linux distributions.

[ You might also like: ifconfig vs ip: What’s Difference and Comparing Network Configuration ]

1. View All Network Interface Settings

The “ ifconfig ” command with no arguments will display all the active interfaces details. The ifconfig command is also used to check the assigned IP address of a server.

2. Display Information of All Network Interfaces

The following ifconfig command with the -a argument will display information of all active or inactive network interfaces on the server. It displays the results for eth0 , lo , sit0 and tun0 .

3. View Network Settings of Specific Interface

Using interface name ( eth0 ) as an argument with the “ ifconfig ” command will display details of the specific network interface.

4. How to Enable a Network Interface

The “ up ” or “ ifup ” flag with interface name ( eth0 ) activates a network interface if it is not inactive state and allowing to send and receive information. For example, “ ifconfig eth0 up ” or “ ifup eth0 ” will activate the eth0 interface.

5. How to Disable a Network Interface

The “ down ” or “ ifdown ” flag with interface name ( eth0 ) deactivates the specified network interface. For example, the “ ifconfig eth0 down ” or “ ifdown eth0 ” command deactivates the eth0 interface if it is in an inactive state.

6. How to Assign an IP Address to Network Interface

To assign an IP address to a specific interface, use the following command with an interface name ( eth0 ) and ip address that you want to set. For example, “ ifconfig eth0 172.16.25.125 ” will set the IP address to interface eth0 .

[ You might also like: How to Configure IP Network with ‘nmtui’ Tool ]

7. How to Assign a Netmask to Network Interface

Using the “ ifconfig ” command with the “ netmask ” argument and interface name as ( eth0 ) allows you to define a netmask to a given interface. For example, “ ifconfig eth0 netmask 255.255.255.224 ” will set the network mask to a given interface eth0 .

8. How to Assign a Broadcast to Network Interface

Using the “ broadcast ” argument with an interface name will set the broadcast address for the given interface. For example, the “ ifconfig eth0 broadcast 172.16.25.63 ” command sets the broadcast address to an interface eth0 .

9. How to Assign an IP, Netmask, and Broadcast to Network Interface

To assign an IP address, Netmask address, and Broadcast address all at once using the “ ifconfig ” command with all arguments as given below.

10. How to Change MTU for a Network Interface

The “ mtu ” argument sets the maximum transmission unit to an interface. The MTU allows you to set the limit size of packets that are transmitted on an interface. The MTU is able to handle a maximum number of octets to an interface in one single transaction.

For example, “ ifconfig eth0 mtu 1000 ” will set the maximum transmission unit to a given set (i.e. 1000 ). Not all network interfaces support MTU settings.

11. How to Enable Promiscuous Mode

What happens in normal mode, when a packet is received by a network card, it verifies that it belongs to itself. If not, it drops the packet normally, but in the promiscuous mode is used to accept all the packets that flow through the network card.

Today’s network tools use the promiscuous mode to capture and analyze the packets that flow through the network interface. To set the promiscuous mode, use the following command.

12. How to Disable Promiscuous Mode

To disable promiscuous mode, use the “ -promisc ” switch that drops back the network interface in normal mode.

13. How to Add New Alias to Network Interface

The ifconfig utility allows you to configure additional network interfaces using the alias feature. To add the alias network interface of eth0 , use the following command. Please note that the alias network address is in the same subnet mask. For example, if your eth0 network ip address is 172.16.25.125 , then the alias ip address must be 172.16.25.127 .

Next, verify the newly created alias network interface address, by using the “ ifconfig eth0:0 ” command.

14. How to Remove Alias to Network Interface

If you no longer required an alias network interface or you incorrectly configured it, you can remove it by using the following command.

15. How to Change the MAC address of Network Interface

To change the MAC ( Media Access Control ) address of an eth0 network interface, use the following command with the argument “ hw ether “. For example, see below.

These are the most useful commands for configuring network interfaces in Linux , for more information and usage of the ifconfig command use the manpages like “ man ifconfig ” at the terminal. Check out some other networking utilities below.

Other Networking Utilities

  • nmcli – a command-line client that is used to control NetworkManager and report network information.
  • Tcmpdump – is a command-line packet capture and analyzer tool for monitoring network traffic.
  • Netstat – is an open-source command-line network monitoring tool that monitors incoming and outgoing network packets traffic.
  • ss (socket statistics) – a tool that prints network socket-related information on a Linux system.
  • Wireshark – is an open-source network protocol analyzer that is used to troubleshoot network-related issues.
  • Munin – is a web-based network and system monitoring application that is used to display results in graphs using rrdtool.
  • Cacti – is a complete web-based monitoring and graphing application for network monitoring.

To get more information and options for any of the above tools, see the man pages by entering “ man toolname ” at the command prompt. For example, to get the information for the “ netstat” tool, use the command “ man netstat “.

35 Practical Examples of Linux Find Command

How to clear ram memory cache, buffer and swap space on linux.

ifconfig(8) — Linux manual page

Name         top, synopsis         top, description         top, address families         top, options         top, notes         top, files         top, bugs         top, see also         top, authors         top, colophon         top.

Pages that refer to this page: getifaddrs(3) ,  if_nameindex(3) ,  if_nametoindex(3) ,  sk98lin(4) ,  wavelan(4) ,  proc(5) ,  arp(8) ,  netstat(8) ,  plipconfig(8) ,  rarp(8) ,  route(8) ,  tc-bfifo(8) ,  tc-pfifo_fast(8)

  • Shell Scripting
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Linux Commands

File and Directory Manipulation

  • ls Command in Linux
  • How to Change the Directory in Linux | cd Command
  • How to Display Current Working Directory in Linux | pwd Command
  • How to Create Directory in Linux | mkdir Command
  • rm command in Linux with examples
  • How to Copy Files and Directories in Linux | cp Command
  • How to Move File in Linux | mv Command
  • How to Create an Empty File in Linux | Touch Command
  • How to View the Content of File in Linux | cat Command
  • grep command in Unix/Linux

File Operations and Compression

  • How to Find a File in Linux | Find Command
  • How to Compress Files in Linux | Tar Command
  • Gzip Command in Linux
  • gunzip command in Linux with examples
  • ZIP command in Linux with examples
  • How to Install Zip and Unzip in Linux?
  • How to Make Script Executable in Linux | chmod Command
  • How to Change File Ownership in Linux | chown Command
  • chgrp command in Linux with Examples
  • How to List Running Processes in Linux | ps Command

Network and Connectivity

  • How to Monitor System Activity in linux | top Command
  • How to Kill a Process in Linux | Kill Command

How to Find Your IP Address in Linux | ifconfig Command

  • How to Check Network Connectivity in Linux | ping Command
  • How do I use SSH to connect to a remote server in Linux | ssh Command
  • How to Securely Copy Files in Linux | scp Command
  • Wget command in Linux/Unix
  • curl command in Linux with Examples
  • How to Compare Files Line by Line in Linux | diff Command
  • Head command in Linux with examples

Text Processing and Manipulation

  • Tail command in Linux with examples
  • How to sort lines in text files in Linux | sort Command
  • AWK command in Unix/Linux with examples
  • Sed Command in Linux/Unix with examples
  • cut command in Linux with examples
  • tr command in Unix/Linux with examples
  • echo command in Linux with Examples
  • export command in Linux with Examples
  • source Command in Linux with Examples
  • How to Display Command History in Linux | history Command

Help and Information

  • apropos command in Linux with Examples
  • info command in Linux with Examples
  • How to Create and Use Alias Command in Linux
  • uname command in Linux with Examples
  • df command in Linux with Examples
  • du command in Linux with examples
  • How to Mount File System in Linux | mount Command
  • ln command in Linux with Examples

System Administration and Control

  • How to Display Path of an Executable File in Linux | Which Command
  • whereis command in Linux with Examples
  • locate command in Linux with Examples
  • How to Display and Set Date and Time in Linux | date Command
  • cal command in Linux with Examples
  • How to Start, Stop and Restart Services in Linux Using systemctl Command
  • shutdown command in Linux with Examples

User and Group Management

  • init command in Linux with examples
  • How to add User in Linux | useradd Command
  • usermod command in Linux with Examples
  • How to Delete User in Linux | userdel Command
  • How to Create a new group in Linux | groupadd command
  • groupmod command in Linux with examples
  • How to Delete a Group in Linux | groupdel command
  • How to Change User Password in Linux | passwd Command
  • Difference Between su and su - Command in Linux

Privilege and Security Management

  • chroot command in Linux with examples
  • file command in Linux with examples
  • hexdump command in Linux with examples
  • wc command in Linux with examples
  • tee command in Linux with examples
  • script command in Linux with Examples
  • How To Generate SSH Key With ssh-keygen In Linux?

Process Management and Control

  • 'crontab' in Linux with Examples
  • at Command in Linux with Examples
  • nohup Command in Linux with Examples
  • bg command in Linux with Examples
  • fg command in Linux with examples
  • Process Control Commands in Unix/Linux
  • Shell Script to Demonstrate Wait Command in Linux

Data Backup and Synchronization

  • rsync command in Linux with Examples
  • screen command in Linux with Examples
  • uniq Command in Linux with Examples

Knowing your IP address is fundamental for network administration, troubleshooting, and various Linux system tasks. In this article, we will explore several methods to find your IP address in a Linux environment. Whether you are a seasoned Linux user or just getting started, understanding these methods will empower you to navigate and manage your network effectively.

How to Find Your IP Address in Linux Using `ifconfig Command:

ifconfig (interface configuration) command is used to configure the kernel-resident network interfaces. It is used at the boot time to set up the interfaces as necessary. After that, it is usually used when needed during debugging or when you need system tuning. Also, this command is used to assign the IP address and netmask to an interface or to enable or disable a given interface.

Syntax of `ifconfig`Command in Linux

  • [ interface ] is the network interface you want to configure or display information for (e.g., eth0, wlan0).
  • [ options ] are various command-line options that can be used to modify the behavior of ifconfig.

Newer versions of some Linux distributions don’t have ifconfig command pre-installed. So, in case, there is an error “ifconfig: command not found” , Then execute the following command to install ifconfig.

Installing net-tools in Linux

For Debian, Ubuntu, and related Linux distributions.

For CentOS or RPM(RedHat Package Manager) based Linux

This will install `ifconfig` along with some other networking commands like arp, route, ipmaddr.

Finding Your Ip Address in Linux Using `ifconfig` Command

To view information about all network interfaces on your Linux system, simply execute the following command:

Finding IP Address in Linux Using `ifconfig`

Finding IP Address in Linux Using `ifconfig`

This command will provide a comprehensive list of all network interfaces along with their respective IP addresses, MAC addresses, and other relevant details.

Options available in `ifconfig` Command in Linux

Here are the most commonly used option in ifconfig command in linux

What is Public and Private IP in Linux

In the realm of networking, both in Linux and other operating systems, IP addresses are categorized as either public or private. These designations are crucial for facilitating communication between devices on a network, whether it’s the global internet or a local intranet. Let’s delve into the distinctions between public and private IP addresses in Linux.

1) How to Find Your Public IP Addresses in Linux:

A public IP address is a globally unique identifier assigned to a device on the internet. It serves as the address by which other devices on the internet can find and communicate with it. Public IP addresses are assigned by the Internet Assigned Numbers Authority (IANA) to Internet Service Providers (ISPs) and other organizations that control access to the global internet.

In Linux, you can determine the public IP address of a system by using external services or commands like curl or wget to query a web service. For example:

This command retrieves your public IP address from a web service.

Public IP addresses are essential for servers, websites, and other devices that need to be directly accessible from the internet. They are globally routable, meaning they can be reached from any location on the internet.

Different Ways to Find Your Public IP Address in Linux

1) Using `wget` with `ifconfig.me` to Find Your IP Address in Linux

Similar to curl , this uses the ifconfig.me service to fetch your public IP address.

Using `wget` with `ifconfig.me` to Find Your IP Address in Linux

Using `wget` with `ifconfig.me` to Find Your IP Address in Linux

2) Using `dig` with `resolver1.opendns.com` to Find Your IP Address in Linux

This command uses the OpenDNS resolver to query your public IP address.

Using `dig` with `resolver1.opendns.com` to Find Your IP Address in Linux

Using `dig` with `resolver1.opendns.com` to Find Your IP Address in Linux

3) Using `curl` with `icanhazip.com`to Find Your IP Address in Linux

This command queries the icanhazip.com service to obtain your public IP address.

 Using `curl` with `icanhazip.com`to Find Your IP Address in Linux

Using `curl` with `icanhazip.com`to Find Your IP Address in Linux

4) Using `wget` with `icanhazip.com` to Find Your IP Address in Linux

Similar to the curl command, this uses the icanhazip.com service to fetch your public IP address.

 Using `wget` with `icanhazip.com` to Find Your IP Address in Linux

Using `wget` with `icanhazip.com` to Find Your IP Address in Linux

5) Using host with dns.google to Find Your IP Address in Linux

This command utilizes the DNS service provided by Google to resolve your public IP address.

Using host with dns.google to Find Your IP Address in Linux

Using host with dns.google to Find Your IP Address in Linux

2) How to Find Your Private IP Addresses in Linux:

Contrastingly, private IP addresses are used within a private network and are not directly accessible from the internet. These addresses are defined in reserved address ranges specified by the Internet Engineering Task Force (IETF) in RFC 1918. The commonly used private IP address ranges are:

  • 10.0.0.0 to 10.255.255.255 (10.0.0.0/8)
  • 172.16.0.0 to 172.31.255.255 (172.16.0.0/12)
  • 192.168.0.0 to 192.168.255.255 (192.168.0.0/16)

These addresses are intended for use in local networks, such as home or corporate intranets. Devices within the same private network can communicate with each other using these private IP addresses, but they rely on a mechanism called Network Address Translation (NAT) to access the internet through a shared public IP address.

In Linux, you can view the private IP addresses of your system using the ifconfig or ip addr commands. For example:

Different Ways to Find Your Private IP Address in Linux

1) Using `hostname` to Find Your IP Address in Linux

The -I option with the hostname command can be used to display the private IP address of your machine.

Using hostname to Find Your IP Address in Linux

Using hostname to Find Your IP Address in Linux

2) Using `nmcli` (NetworkManager command-line tool) to Find Your IP Address in Linux

If you’re using NetworkManager, this command filters out IPv4 addresses associated with your network interfaces.

Using nmcli to Find Your IP Address in Linux

Using nmcli to Find Your IP Address in Linux

3) Using `awk` with `ifconfig` to Find Your IP Address in Linux

This command uses the awk tool to filter and print only the private IP addresses from the ifconfig output.

Using `awk` with `ifconfig` to Find Your IP Address in Linux

Using `awk` with `ifconfig` to Find Your IP Address in Linux

4) Using `grep` with `ip` to Find Your IP Address in Linux

This command uses grep with Perl-compatible regular expressions to extract private IP addresses from the ip command output.

Using `grep` with `ip` to Find Your IP Address in Linux

Using `grep` with `ip` to Find Your IP Address in Linux

5) Using `ss` (socket statistics) command to Find Your IP Address in Linux

This complex command lists the IP addresses to which the system is listening for incoming connections.

Using `ss` (socket statistics) command to Find Your IP Address in Linux

Using `ss` (socket statistics) command to Find Your IP Address in Linux

Frequently Asked Question

1) how can i quickly check my ip address in linux using the command line.

You can use the ` ip` command with the ` address` option. Open a terminal and type ` ip address` or ` ip a` , and look for the line starting with “inet” followed by your IP address.

2) How to specificity display only the public IP address in Linux?

You can use a command like ` curl` or ` wget` to fetch your public IP from a web service. For example: curl ifconfig.me or wget -qO- ifconfig.me

3) Can I find my IP address in Linux using GUI tools?

Yes, many Linux distributions come with network management tools that provide a graphical interface. For example, in Ubuntu, you can use the network settings or system monitor to find your IP address.

4) How do I find the IP address of a specific network interface in Linux?

You can use the ` ifconfig` or ` ip address` command followed by the interface name. For example: ifconfig eth0 or ip address show eth0 This will display details, including the IP address, for the specified interface.

5) How can I display detailed information about all network interfaces in Linux?

You can use the ` ifconfig` or ` ip address` show command to display comprehensive information about all network interfaces. For example: ifconfig or ip address show It will display details such as IP addresses, netmasks, and other network-related information for all available interfaces on your Linux system.

In this article, we’ve explored how to find your IP address in Linux using the ifconfig command. We also discuss what is private and public IP address and how to display both of the IP Address .This essential skill is crucial for effective network management. Whether you’re a seasoned Linux user or a beginner, understanding these simple commands empowers you to navigate and control your network effortlessly.

Please Login to comment...

Similar reads.

author

  • linux-command
  • Linux-networking-commands
  • CBSE Exam Format Changed for Class 11-12: Focus On Concept Application Questions
  • 10 Best Waze Alternatives in 2024 (Free)
  • 10 Best Squarespace Alternatives in 2024 (Free)
  • Top 10 Owler Alternatives & Competitors in 2024
  • 30 OOPs Interview Questions and Answers (2024)

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

Select Your Language

Infrastructure and management.

  • Red Hat Enterprise Linux
  • Red Hat Satellite
  • Red Hat Subscription Management
  • Red Hat Insights
  • Red Hat Ansible Automation Platform

Cloud Computing

  • Red Hat OpenShift
  • Red Hat OpenStack Platform
  • Red Hat OpenShift Container Platform
  • Red Hat OpenShift AI
  • Red Hat OpenShift Dedicated
  • Red Hat Advanced Cluster Security for Kubernetes
  • Red Hat Advanced Cluster Management for Kubernetes
  • Red Hat Quay
  • OpenShift Dev Spaces
  • Red Hat OpenShift Service on AWS
  • Red Hat Gluster Storage
  • Red Hat Hyperconverged Infrastructure
  • Red Hat Ceph Storage
  • Red Hat OpenShift Data Foundation
  • Red Hat Runtimes
  • Red Hat JBoss Enterprise Application Platform
  • Red Hat Data Grid
  • Red Hat JBoss Web Server
  • Red Hat build of Keycloak
  • Red Hat support for Spring Boot
  • Red Hat build of Node.js
  • Red Hat build of Quarkus

Integration and Automation

  • Red Hat Application Foundations
  • Red Hat Fuse
  • Red Hat AMQ
  • Red Hat 3scale API Management
  • Single-page

Language and Page Formatting Options

Red hat training.

A Red Hat training course is available for Red Hat Enterprise Linux

3.6. Configuring IP Networking with ip Commands

Assigning a static address using ip commands, configuring multiple addresses using ip commands, quick links.

  • Subscriptions
  • Support Cases
  • Customer Service
  • Product Documentation
  • Contact Customer Portal
  • Customer Portal FAQ
  • Log-in Assistance
  • Trust Red Hat
  • Browser Support Policy
  • Accessibility
  • Awards and Recognition

Related Sites

  • developers.redhat.com
  • connect.redhat.com
  • cloud.redhat.com

Systems Status

  • Red Hat Subscription Value
  • About Red Hat
  • Red Hat Jobs

Red Hat legal and privacy links

  • Contact Red Hat
  • Red Hat Blog
  • Diversity, equity, and inclusion
  • Cool Stuff Store
  • Red Hat Summit
  • Privacy statement
  • Terms of use
  • All policies and guidelines
  • Digital accessibility

Linux Ipconfig

Switch to English

  • Introduction

Table of Contents

Understanding Linux Network Configuration

Using the ifconfig command, using the ip command, tips and tricks, common error-prone cases.

  • Linux networking commands are used to view, set, change, or troubleshoot network settings on a system.
  • The "ifconfig" command, short for "interface configuration," was the original tool for network interface configuration on Linux systems. It allows users to view and control the network configuration of a system.
  • Despite its popularity, the "ifconfig" command has been deprecated in modern Linux distributions in favor of the "ip" command, which offers more features and capabilities.
  • The output will include details about all network interfaces currently active on your system, including ethernet interfaces (eth0, eth1, etc.), Wi-Fi (wlan0, wlan1), loopback interface (lo), and more.
  • Each interface section will provide information such as the IP address, broadcast address, subnet mask, MAC address, and received and transmitted packets.
  • This command will display the details of all network interfaces, similar to "ifconfig".
  • The "ip" command is often used with several sub-commands like "addr" (for IP address), "link" (for physical interface), "route" (for routing table), etc.
  • Both "ifconfig" and "ip" commands should be run as a root user or with sudo permissions to modify network configurations.
  • If "ifconfig" command is not found on your system, it may be because it's deprecated. You can still install it using the package manager of your Linux distribution, but consider using the "ip" command as it's more powerful and up-to-date.
  • One common mistake is trying to configure a network interface that doesn’t exist. Always check the available network interfaces on your system before configuration.
  • Another common error is incorrect subnet mask or gateway configuration, which can lead to network communication issues. Always verify these parameters.
  • Python (302)
  • Javascript (658)
  • HTML5 (534)
  • Object-oriented Programming (120)
  • React (280)
  • Node.js (264)
  • Data Structure (172)
  • WordPress (226)
  • jQuery (326)
  • Angular (306)
  • Google Ads (172)
  • Django (253)
  • Digital Marketing (196)
  • TypeScript (288)
  • Redux (268)
  • Kotlin (290)
  • MongoDB (262)
  • Laravel (252)
  • Swift (172)
  • Cloud Computing (286)
  • Agile/Scrum (208)
  • ASP.NET (254)
  • UI/UX Design (170)
  • Analytics (258)
  • Linux (252)
  • Search Engine Optimization (936)
  • Github (240)
  • Bootstrap (264)
  • Machine Learning (237)
  • Project Management (244)
  • REST API (270)
  • Oracle (264)
  • Excel (276)
  • Adobe Photoshop (232)
  • Data Science (235)
  • Artificial Intelligence (262)
  • Vue.js (280)
  • Hadoop (244)
  • GoLang (266)
  • Scala (262)
  • Solidity (252)
  • Ruby on Rails (246)
  • Augmented Reality (218)
  • VidGenesis (1317)
  • Virtual Reality (88)
  • Unreal Engine (78)

Popular Articles

  • Linux Head Command (Dec 16, 2023)
  • Linux Get Time (Dec 16, 2023)
  • Linux Generate Ssh Key (Dec 16, 2023)
  • Linux Environment Variables (Dec 16, 2023)
  • Linux Disk Usage (Dec 16, 2023)

How to use ifconfig in Linux

Introduction.

To configure, manage, and query network interface parameters through the command-line interface or in a system configuration script, use the “interface configuration” (abbreviated as “ifconfig”) program on Unix/Linux operating systems. The “ifconfig” command can display the current network configuration information, configure a network interface’s hardware address, IP address, netmask, or broadcast address, create an alias for the network interface, and enable or deactivate network interfaces. The “Useful “ifconfig” Commands” and their real-world applications are covered in this article. They could be very useful to you when managing and configuring network interfaces in Linux systems.

View All Network Interface Settings

Without any parameters, the “ifconfig” program will list all the details of the current interfaces. The assigned IP address of a server can also be checked using the ifconfig command.

Display Information for Every Network Interface

The details of any active or inactive network interfaces on the server will be shown by the ifconfig command that follows with the -a argument. The outcomes for eth0, lo, sit0, and tun0 are shown.

View the Network Settings for a Particular Interface

When the “ifconfig” command is used with the argument interface name (eth0), the specific network interface’s specifications are shown.

Activating a Network Interface

If a network interface is not in an inactive state, the “up” or “ifup” flag with the interface name (eth0) activates it and enables data transmission and reception. For instance, the eth0 interface can be activated with “ifconfig eth0 up” or “ifup eth0.”

Disable a Network Interface

The given network interface is turned down when the “down” or “ifdown” flag is present with the interface name (eth0). For instance, if the eth0 interface is inactive, the command “ifconfig eth0 down” or “ifdown eth0” deactivates it.

Give a Network Interface an IP Address

Use the following command with the interface name (eth0) and desired IP address to allocate an IP address to a particular interface. For instance, “ifconfig eth0 172.18.22.120” will configure interface eth0’s IP address.

Assign a Netmask to Network Interface

It is possible to define a netmask for a specific interface by using the “ifconfig” command with the “netmask” option and the interface name (eth0). Ifconfig eth0 netmask 255.255.255.240, for instance, will configure the network mask for the specified eth0 interface.

Assign a Broadcast to Network Interface

The broadcast address for the specified interface will be set when the “broadcast” parameter is used with the interface name. For instance, the command “ifconfig eth0 broadcast 172.16.25.63” changes the interface eth0’s broadcast address to 172.20.25.175.

Broadcast, Netmask, and Assign an IP to a Network Interface

Use the “ifconfig” command with every option listed below to assign an IP address, Netmask address, and Broadcast address all at once.

Change MTU for a Network Interface

The “MTU” option determines the maximum transmission unit to an interface. By adjusting the MTU, you can control the maximum size of packets transmitted on an interface. A maximum number of octets can be sent to an interface using the MTU in a single transaction.

For instance, the command “ifconfig eth0 mtu 1000” will set the maximum transmission unit to a specified number (i.e., 1000). All network interfaces do not support MTU adjustments.

Enable Promiscuous Mode

When a network card receives a packet in normal mode, it checks that the packet belongs to that card. However, the promiscuous mode accepts all packets that run via the network card. If not, it drops the packet normally.

The packets that pass across the network interface are captured and examined by modern network tools using the promiscuous mode. Use the following command to set the promiscuous mode.

Disable Promiscuous Mode

Use the “-promisc” switch to drop back to the network interface in normal mode and disable promiscuous mode.

Add New Alias to Network Interface

Using the alias functionality of the ifconfig program, you can configure extra network interfaces. Use the following command to add the alias network interface for eth0. Please be aware that the alias network address belongs to the same subnet mask. For instance, if the eth0 network IP address is 172.16.25.130, the alias IP address must be 172.16.25.137.

Next, use the “ifconfig eth0:0” command to confirm the network interface address of the newly formed alias.

Remove Alias to Network Interface

The following command can be used to eliminate an alias network interface if you no longer need it or if you misconfigured it.

Modify the Network Interface’s MAC Address

Use the following command with the option “hw ether” to modify an eth0 network interface’s MAC (Media Access Control) address. See the example below.

These are the most helpful commands for setting network interfaces in Linux. Use the man command “man ifconfig” at the terminal for more details on how to use the ifconfig command.

Leave a Reply Cancel reply

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

Save my name, email, and website in this browser for the next time I comment.

Recent Posts

  • How to check SMTP Health on Linux?
  • MySQLTuner – Optimizing MySQL Performance
  • How to increase database performance
  • How to Fine-Tune Linux Kernel Parameters
  • Optimizing PHP-FPM for Better Performance

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

How do I add an additional IP address to an interface in Ubuntu 14

I want to have the wired interface simultaneously obtain a DHCP address, and also alias a fixed address so I can communicate with a device with a fixed IP address on a different subnet over the same link.

When searching for IP address aliasing in Ubuntu, I found this article How do I add interface aliases using Network Manager GUI? . Unfortunately, the Edit Connections GUI in Ubuntu 14 does not have the "additional addresses" button.

Where has this functionality moved?

Community's user avatar

  • 1 I have updated that answer with another screenshot, see if it helps. But at any rate, I don't think the GUI allows you to have a DHCP and a static address at the same time - multiple static addresses are fine. –  muru Feb 14, 2015 at 17:27
  • Correct - I tried setting it to manual, adding my static address and switching back to DHCP. Doing so deletes any manual addresses. –  tim11g Feb 14, 2015 at 18:05

4 Answers 4

Skip the gui and do it via command line.

The following link provides detailed information on how to create the alias on a temporary basis, as well as how to edit the interfaces file to make the change permanent.

http://www.cyberciti.biz/faq/linux-creating-or-adding-new-network-alias-to-a-network-card-nic/

Information from site in case of site death:

ifconfig command line

You can use ifconfig command to configure a network interface and alias. For example:

  • eth0 NIC IP 192.168.1.5
  • eth0:0 first NIC alias: 192.168.1.6

To setup eth0:0 alias type the following command as the root user:

Verify alias is up and running using following command:

However, if you reboot the system you will lost all your alias. To make it permanent you need to add it network configuration file.

Append the following to the file (This is in addition to existing information, not a replacement for it)

Save and close the file. Restart the network:

Dave's user avatar

  • Thanks! the "ifconfig eth0:0 192.168.1.6 up" command works great. I don't need it to persist, so that is a perfect solution. –  tim11g Feb 14, 2015 at 18:11
  • 2 Just note: ip utility is now recommended way to manupulate interfaces ( serverfault.com/a/458639/115256 ). Here's the HowTo: askubuntu.com/a/547297/53738 –  dess Jul 8, 2015 at 5:50
  • Why is there no gateway entry in the config above? –  Colin 't Hart Jun 1, 2016 at 9:47
  • 3 @Colin'tHart: you can only have one "default gateway" (there are special cases, but that is another story), so if the "main" network config already have a gateway, you should not put any in this alias. If the "main" network have no gateway, you can add in the alias the gateway, specially if it is related to this ip range –  higuita Jul 13, 2016 at 13:37

In order to add an address temporarily use ip :

For example to install OpenWRT on some old devices:

https://openwrt.org/toh/avm/avm_fritz_wlan_repeater_450e

  • How do you make that change permanent (in 2022)? –  Gwyneth Llewelyn Oct 12, 2022 at 17:14
  • @GwynethLlewelyn Edit the correct configuration file for your system. –  ceving Oct 14, 2022 at 8:37

I just learned a trick from my colleague which involve the following:

If say eth_lan0 is set as the name of your wired network and has first been configured with the IP 192.168.1.2 , say with something like netplan , you can then add an alias to connect to another internal network say with an IP with the pattern 10.42.0.x with the following:

This assumes that the IP 10.42.0.2 has not yet been assigned to your LAN and that your host is connected to both networks, one with IP 192.168.1.x and the other with 10.42.0.x . Check if you have been successful by running ifconfig to see if the alias has been set. Then, it would be recommended to ping the hosts you are trying to connect on the two local networks to make sure everything runs as expected.

Kris Stern's user avatar

You can use the below steps to add IP Address in a ubuntu network interface.

Login to Ubuntu server via ssh.

Hit the Following Command.

nano /etc/network/interfaces

  • Enter the interface alias eth0:0 as mentioned in below.

( Note : If you already have interface alias eth0:0, you can add eth0:1 or eth0:2 for additional IP Address)

  • Below Command will up the added interface alias within the network.

ifconfig eth0:0 1*3.2*8.149.*** up

  • Restart the network service.

/etc/init.d/networking restart

  • check the newly added ip address with the below command.

It is Done.

Hiren Parghi's user avatar

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged alias ip-address ..

  • The Overflow Blog
  • How do mixture-of-experts layers affect transformer models?
  • What a year building AI has taught Stack Overflow
  • Featured on Meta
  • New Focus Styles & Updated Styling for Button Groups
  • Upcoming initiatives on Stack Overflow and across the Stack Exchange network
  • AI-generated content is not permitted on Ask Ubuntu
  • Let's organize some chat workshops

Hot Network Questions

  • Is there a way to take away an action in D&D 5e?
  • Scratch on a Canadian passport
  • Asymptotic behavior of the "Cauchy square" series
  • How can I make a custom header in less? Or alternatively, how can I open two files simultaneously in less?
  • When should I use a verb or a gerund/noun after 'to' in English?
  • poly-filler in this particular sentence
  • Is there a mathematical formula or a list of frequencies (Hz) of notes?
  • Is it safe to eat yellow yam, which I pan-fried?
  • When providing examples, why they switch from "to Verb" to "Verbing" in this sentence?
  • Is there some source relating real poisons with ad&d (1e/2e) poison chart?
  • Extreme anxiety before boarding a plane
  • "You are in emergency mode"
  • Residual finiteness and a gluing problem
  • An algebra student wants to learn to type commutative diagrams on LaTeX?
  • Should I initialize third party libraries in a class or function?
  • Difficult sentence from Leibniz's Historia Inventionis Phosphori?
  • Hydrogen bonding autocorrelations
  • Are all validities isomorphic or equivalent to valid proofs?
  • Can religions die?
  • Is it possible to have a stable black hole that does not evaporate?
  • Why infinite spheres and not just two?
  • USB-C Splitter for external SSD enclosure
  • What's a word that would describe "Technical Aptitude" as an "attribute"
  • How do I express a negative premise in Coq?

assign ip ifconfig

How-To Geek

How to use the ip command on linux.

It is time to break up with ifconfig.

Quick Links

How the ip command works, using ip with addresses, display only ipv4 or ipv6 addresses, display information for a single interface, adding an ip address, deleting an ip address, using ip with network interfaces, starting and stopping links, using ip with routes, display information for a single route, adding a route, taken route, not taken root, key takeaways.

  • The ip command has replaced the older ifconfig command in modern versions of Linux.
  • The ip command allows you to configure IP addresses, network interfaces, and routing rules on the fly without rebooting.
  • Run "ip addr" in the Terminal to get your PC's local IP address.

You can configure IP addresses, network interfaces, and routing rules on the fly with the Linux ip command. We'll show you how you can use this modern replacement of the classic (and now deprecated) ifconfig .

With the ip command, you can adjust the way a Linux computer handles IP addresses, network interfaces controllers (NICs), and routing rules . The changes also take immediate effect — you don't have to reboot. The ip command can do a lot more than this, but we'll focus on the most common uses in this article.

The ip command has many subcommands, each of which works on a type of object, such as IP addresses and routes. There are, in turn, many options for each of these objects. It's this richness of functionality that gives the ip command the granularity you need to perform what can be delicate tasks. This isn't ax work — it calls for a set of scalpels.

We'll look at the following objects:

  • Address : IP addresses and ranges.
  • Link : Network interfaces, such as wired connections and Wi-Fi adapters.
  • Route : The rules that manage the routing of traffic sent to addresses via interfaces ( links ).

Obviously, you first have to know the settings you're dealing with. To discover which IP addresses your computer has, you use the ip command with the object address . The default action is show , which lists the IP addresses. You can also omit show and abbreviate address as "addr" or even "a."

The following commands are all equivalent:

ip address show

ip addr show

We see two IP addresses, along with a lot of other information. IP addresses are associated with network interface controllers (NICs). The ip command tries to be helpful and provides a bunch of information about the interface, too.

The first IP address is the (internal) loopback address used to communicate within the computer. The second is the actual (external) IP address the computer has on the local area network (LAN).

Let's break down all the information we received:

  • lo : The network interface name as a string.
  • <LOOPBACK,UP,LOWER_UP>: This is a loopback interface. It's UP , meaning it's operational. The physical networking layer (layer one) is also up.
  • mtu 65536: The maximum transfer unit. This is the size of the largest chunk of data this interface can transmit.
  • qdisc noqueue: A qdisc is a queuing mechanism. It schedules the transmission of packets. There are different queuing techniques called disciplines. The noqueue discipline means "send instantly, don't queue." This is the default qdisc discipline for virtual devices, such as the loopback address.
  • state UNKNOWN: This can be DOWN (the network interface is not operational), UNKNOWN (the network interface is operational but nothing is connected), or UP (the network is operational and there is a connection).
  • group default: Interfaces can be grouped logically. The default is to place them all in a group called "default."
  • qlen 1000: The maximum length of the transmission queue.
  • link/loopback: The media access control (MAC) address of the interface.
  • inet 127.0.0.1/8: The IP version 4 address. The part of the address after the forward-slash ( / ) is Classless Inter-Domain Routing notation (CIDR) representing the subnet mask. It indicates how many leading contiguous bits are set to one in the subnet mask. The value of eight means eight bits. Eight bits set to one represents 255 in binary, so the subnet mask is 255.0.0.0.
  • scope host: The IP address scope. This IP address is only valid inside the computer (the "host").
  • lo: The interface with which this IP address is associated.
  • valid_lft: Valid lifetime. For an IP version 4 IP address allocated by Dynamic Host Configuration Protocol (DHCP), this is the length of time the IP address is considered valid and able to make and accept connection requests.
  • preferred_lft: Preferred lifetime. For an IP version 4 IP address allocated by DHCP, this is the amount of time the IP address can be used with no restrictions. This should never be larger than the valid_lft value.
  • inet6 : The IP version 6 address, scope , valid_lft , and preferred_lft .

The physical interface is more interesting, as we'll show below:

  • enp0s3: The network interface name as a string. The "en" stands for ethernet, "p0" is the bus number of the ethernet card, and "s3" is the slot number.
  • <BROADCAST,MULTICAST,UP,LOWER_UP>: This interface supports broad- and multicasting , and the interface is UP (operational and connected). The hardware layer of the network (layer one) is also UP .
  • mtu 1500: The maximum transfer unit this interface supports.
  • qdisc fq_codel: The scheduler is using a discipline called "Fair Queuing, Controlled Delay." It's designed to provide a fair share of the bandwidth to all the traffic flows that use the queue.
  • state UP: The interface is operational and connected.
  • group default: This interface is in the "default" interface group.
  • link/ether: The MAC address of the interface.
  • inet 192.168.4.26/24: The IP version 4 address. The "/24" tells us there are 24 contiguous leading bits set to one in the subnet mask. That's three groups of eight bits. An eight-bit binary number equates to 255; therefore, the subnet mask is 255.255.255.0.
  • brd 192.168.4.255: The broadcast address for this subnet.
  • scope global: The IP address is valid everywhere on this network.
  • dynamic: The IP address is lost when the interface goes down.
  • noprefixroute: Do not create a route in the route table when this IP address is added. Someone has to add a route manually if he wants to use one with this IP address. Likewise, if this IP address is deleted, don't look for a route to delete.
  • enp0s3: The interface with which this IP address is associated.
  • valid_lft: Valid lifetime. The time the IP address will be considered valid; 86,240 seconds is 23 hours and 57 minutes.
  • preferred_lft: Preferred lifetime. The time the IP address will operate without any restrictions.
  • inet6: The IP version 6 address, scope , valid_lft , and preferred_lft .

If you want to limit the output to the IP version 4 addresses, you can use the -4 option, as follows:

If you want to limit the output to the IP version 6 addresses, you can use the -6 option, as follows:

If you want to see the IP address information for a single interface, you can use the show and dev options, and name the interface, as shown below:

ip addr show dev lo

ip addr show dev enp0s3

You can also use the -4 or -6 flag to further refine the output so you only see that in which you're interested.

If you want to see the IP version 4 information related to the addresses on interface enp0s3 , type the following command:

ip -4 addr show dev enp0s3

You can use the add and dev options to add an IP address to an interface. You just have to tell the ip command which IP address to add, and to which interface to add it.

We're going to add the IP address 192.168.4.44 to the enp0s3 interface. We also have to provide the CIDR notation for the subnet mask.

We type the following:

sudo ip addr add 192.168.4.44/24 dev enp0s3

We type the following to take another look at the IP version 4 IP addresses on this interface:

The new IP address is present on this network interface. We jump on another computer and use the following command to see if we can ping the new IP address :

ping 192.168.4.44

The IP address responds and sends back acknowledgments to the pings. Our new IP address is up and running after one simple ip command.

To delete an IP address, the command is almost the same as the one to add one, except you replace add with del , as shown below:

sudo ip addr del 192.168.4.44/24 dev enp0s3

If we type the following to check, we see the new IP address has been deleted:

You use the link object to inspect and work with network interfaces. Type the following command to see the interfaces installed on your computer:

ip link show

To see a single network interface, just add its name to the command, as shown below:

ip link show enp0s3

You can use the set option with either up or down to stop or start a network interface option. You also have to use sudo , as shown below:

sudo ip link set enp0s3 down

We type the following to take a look at the network interface:

The state of the network interface is DOWN . We can use the up option to restart a network interface, as shown below:

sudo ip link set enp0s3 up

We type the following to do another quick check on the state of the network interface:

The network interface was restarted, and the state is shown as UP .

With the route object, you can inspect and manipulate routes. Routes define to where network traffic to different IP addresses is forwarded, and through which network interface.

If the destination computer or device shares a network with the sending computer, the sending computer can forward the packet directly to it.

However, if the destination device is not directly connected, the sending computer forwards the packet to the default router. The router then decides where to send the packet.

To see the routes defined on your computer, type the following command:

Let's take a look at the info we received:

  • default: The default rule. This route is used if none of the other rules match what's being sent.
  • via 192.168.4.1: Routes the packets via the device at 192.168.4.1. This is the IP address of the default router on this network.
  • dev enp0s3: Use this network interface to send the packets to the router.
  • proto dhcp: The routing protocol identifier. DHCP means the routes will be determined dynamically.
  • metric 100: An indication of the preference of the route compared to others. Routes with lower metrics are preferentially used over those with higher metrics. You can use this to give preference to a wired network interface over a Wi-Fi one.

The second route governs traffic to the IP range of 169.254.0.0/16. This is a zero-configuration network , which means it tries to self-configure for intranet communication. However, you can't use it to send packets outside the immediate network.

The principle behind zero-configuration networks is they don't rely on DHCP and other services being present and active. They only need to see TCP/IP in order to self-identify to each of the other devices on the network.

Let's take a look:

  • 169.254.0.0/16: The range of IP addresses this routing rule governs. If the computer communicates on this IP range, this rule cuts in.
  • dev enp0s3: The network interface the traffic governed by this route will use.
  • scope link : The scope is link , which means the scope is limited to the network to which this computer is directly connected.
  • metric 1000 : This is a high metric and isn't a preferred route.

The third route governs traffic to the IP address range of 192.168.4.0/24. This is the IP address range of the local network to which this computer is connected. It's for communication across, but within, that network.

Let's break it down:

  • 192.168.4.1/24: The range of IP addresses this routing rule governs. If the computer communicates within this IP range, this rule triggers and controls the packet routing.
  • dev enp0s3: The interface through which this route will send packets.
  • proto kernel: The route created by the kernel during auto-configuration.
  • scope link: The scope is link , which means the scope is limited to the immediate network to which this computer is connected.
  • src 192.168.4.26: The IP address from which packets sent by this route originate.
  • metric 100: This low metric indicates a preferred route.

If you want to focus on the details of a particular route, you can add the list option and IP address range of the route to the command as follows:

ip route list 192.168.4.0/24

We just added a new network interface card to this computer. We type the following and see it's showing up as enp0s8 :

We'll add a new route to the computer to use this new interface. First, we type the following to associate an IP address with the interface:

sudo ip addr add 192.168.121.1/24 dev enp0s8

A default route using the existing IP address is added to the new interface. We use the delete option, as shown below, to delete the route and provide its details:

sudo ip route delete default via 192.168.4.1 dev enp0s8

We'll now use the add option to add our new route. The new interface will handle network traffic in the 192.168.121.0/24 IP address range. We'll give it a metric of 100; because it will be the only route handling this traffic, the metric is pretty much academic.

sudo ip route add 192.168.121.0/24 dev enp0s8 metric 100

Now, we type the following to see what it gives us:

Our new route is now in place. However, we still have the 192.168.4.0/24 route that points to interface enp0s8 — we type the following to remove it:

sudo ip route delete 192.168.4.0/24 dev enp0s8

We should now have a new route that points all traffic destined for IP range 192.168.121.0/24 through interface enp0s8 . It should also be the only route that uses our new interface.

We type the following to confirm:

The great thing about these commands is they're not permanent. If you want to clear them, just reboot your system. This means you can experiment with them until they work the way you want. And it's a very good thing if you make a terrible mess of your system — a simple reboot will restore order.

On the other hand, if you want the changes to be permanent, you have to do some more work. Exactly what varies depending on the distribution family, but they all involve changing config files.

This way, though, you can test-drive commands before you make anything permanent.

IMAGES

  1. Linux ifconfig Command Explained With 19 Practical Examples

    assign ip ifconfig

  2. How to use IFCONFIG on Debian

    assign ip ifconfig

  3. Ipconfig Mac OS X

    assign ip ifconfig

  4. A Step-By-Step Guide to Install and Use ifconfig on CentOS

    assign ip ifconfig

  5. How To Install And Use Ifconfig On CentOS 7

    assign ip ifconfig

  6. How to Find Your IP Address in Linux

    assign ip ifconfig

VIDEO

  1. ipconfig/ip/ifconfig CompTIA Security+

  2. how to assign ip address to outdoor cpe5210 router

  3. How to Assign IP Address to PCs ( IPv4 & IPv6 ) and Sharing Resources

  4. ipconfig command

  5. configure ip address in linux method 2

  6. Ip Address Settings With Windows 11 For Internet Connection

COMMENTS

  1. Linux ifconfig Command

    With the ifconfig command, you can assign an IP address and netmask to a network interface. Use the following syntax to assign the IP address and netmask: ifconfig [interface-name] [ip-address] netmask [subnet-mask] For example, to assign the IP address 192.168..101 and netmask 255.255.. to the interface eth0, you would run:

  2. 15 Useful "ifconfig" Commands to Configure Network in Linux

    To assign an IP address to a specific interface, use the following command with an interface name ... The ifconfig utility allows you to configure additional network interfaces using the alias feature. To add the alias network interface of eth0, use the following command. Please note that the alias network address is in the same subnet mask.

  3. Linux ifconfig Command Explained With 19 Practical Examples

    The ifconfig command allows users to associate additional IP addresses with an interface using an IP alias. Create an alias IP with the following command: sudo ifconfig [interface_name]:[alias_number] [alias_IP] Note that the alias IP must belong to the same netmask. For example, the IP address for enp0s3 is 10.0.2.15.

  4. ifconfig Command in Linux with Practical Examples

    The ifconfig command follows a specific syntax to perform various operations. The basic syntax is as follows: ifconfig [-a] [-v] [-s] <interface> [ [<AF>] <address>] Here, <interface> refers to the name of the network interface, and <address> is the IP address that you want to assign. It's important to note that configurations set with the ...

  5. Linux Ifconfig Command

    U se the ifconfig command followed by the name of the interface and the IP address you want to assign to set the IP address for the interface. Here's the syntax: # ifconfig [interface_name] [IP_address] Let's see a basic example where we assign the IP address 10.0.2.12 to eno0: # ifconfig en o0 10.0.2.12

  6. How to use ifconfig command in Linux

    Imagine you're setting up a local web server that requires a static IP address to ensure it's consistently accessible at the same address. We'll use ifconfig to assign a static IP address to the eth0 network interface. Step 1: Check current network interface configuration. First, let's check the current configuration of our network ...

  7. 15 Useful "ifconfig" Commands to Configure Network in Linux

    9. How to Assign an IP, Netmask, and Circulate to Network Serial. To assign an IP address, Netmask address, and Broadcast address all at once using the "ifconfig" command with all arguments the given below. [[email protected] ~]# ifconfig eth0 172.16.25.125 netmask 255.255.255.224 broadcast 172.16.25.63 10. How up Modify MTU for a Network ...

  8. Linux Ifconfig Command Help and Examples

    For example, to assign the IP address 69.72.169.1 to the interface wlan0, use the command: sudo ifconfig wlan0 69.72.169.1. To assign a network mask to an interface, use the keyword netmask and the netmask address. For instance, to configure the interface eth1 to use a network mask of 255.255.255.0, the command would be:

  9. Linux networking: ifconfig versus ip

    To assign an IP address to a given interface, you use the following syntax: [root@rhel ~]# ifconfig [interface] [IP] For example: [root@rhel ~]# ifconfig eth0 192.168..1. Assigning a netmask to an interface. To assign a netmask to an interface, you use the following:

  10. The "ifconfig" Command in Linux [6+ Practical Examples]

    Example 3: Assigning IP Address to an Interface Using the "ifconfig" Command in Linux. You can add a new IP address to your available network device using the ifconfig command in Linux. You must run the command as the superuser using the sudo keyword to achieve this task. The IP address needs to be

  11. How to set a static IP Address from the Command Line in GNU/Linux using

    Im a beginner of Linux i tried to change static IP on ubuntu server 20.04 server in the method of below command, It has changing my IP and get pinging but after restarting NO IP showing on ifconfig. or ip a . waiting for your valuable reply. sudo ifconfig eth0 192.168.1.2 netmask 255.255.255.0; sudo route add default gw 192.168.1.1 eth0;

  12. ifconfig Command in Linux with Examples

    'ifconfig' also enables users to configure network interfaces with specific parameters. For instance, to assign an IP address to a network interface, you can use the following command: sudo ifconfig eth0 netmask . Replace and with the IP address and netmask you want to assign to the 'eth0' interface, respectively.

  13. 15 Useful "ifconfig" Commands to Configure Network ...

    To assign an IP address to a specific interface, use the following command with an interface name (eth0) and ip address that you want to set. For example, "ifconfig eth0 172.16.25.125" will set the IP address to interface eth0. [[email protected] ~]# ifconfig eth0 172.16.25.125 [ You might also like: How to Configure IP Network with ...

  14. ifconfig(8)

    Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed. If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argument is given ...

  15. How to Change Your IP Address From the Command Line in Linux

    To get started, type. ifconfig. at the terminal prompt, and then hit Enter. This command lists all network interfaces on the system, so take note of the name of the interface for which you want to change the IP address. To change the settings, you also use the ifconfig command, this time with a few additional parameters.

  16. How to Find Your IP Address in Linux

    Also, this command is used to assign the IP address and netmask to an interface or to enable or disable a given interface. Syntax of `ifconfig`Command in Linux ifconfig [interface] [options] ... You can use the ` ifconfig` or ` ip address` command followed by the interface name. For example: ifconfig eth0. or .

  17. 3.6. Configuring IP Networking with ip Commands Red Hat Enterprise

    As the ip utility supports assigning multiple addresses to the same interface it is no longer necessary to use the alias interface method of binding multiple addresses to the same interface. The ip command to assign an address can be repeated multiple times in order to assign multiple address. For example: ~]# ip address add 192.168.2.223/24 dev enp1s0 ~]# ip address add 192.168.4.223/24 dev ...

  18. How To Change IP Address on Linux

    $ which ifconfig /usr/sbin/ifconfig. To change your IP address on Linux, use the "ifconfig" command followed by the name of your network interface and the new IP address to be changed on your computer. To assign the subnet mask, you can either add a "netmask" clause followed by the subnet mask or use the CIDR notation directly ...

  19. Linux Network Configuration: Mastering the Ifconfig and IP Commands

    The "ip" command is a powerful tool for network configuration in Linux. A simple example of its use is: bash ip addr show. This command will display the details of all network interfaces, similar to "ifconfig". The "ip" command is often used with several sub-commands like "addr" (for IP address), "link" (for physical interface), "route" (for ...

  20. How to use ifconfig in Linux

    For instance, "ifconfig eth0 172.18.22.120" will configure interface eth0's IP address. ifconfig eth0 172.20.25.120 Assign a Netmask to Network Interface. It is possible to define a netmask for a specific interface by using the "ifconfig" command with the "netmask" option and the interface name (eth0).

  21. How can I (from CLI) assign multiple IP addresses to one interface?

    With the new toolkit, it is as easy as with the old to add new ip addresses: ip addr add 192.168.1.1/24 dev eth0 When looking with ip addr show again, you see the second ip address assigned to the interface:. 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff inet 192.168..100/24 brd 192.168..255 scope ...

  22. How do I add an additional IP address to an interface in Ubuntu 14

    sudo ifconfig eth_lan0:1 10.42..2 This assumes that the IP 10.42..2 has not yet been assigned to your LAN and that your host is connected to both networks, one with IP 192.168.1.x and the other with 10.42..x. Check if you have been successful by running ifconfig to see if the alias has been set. Then, it would be recommended to ping the ...

  23. How to Use the ip Command on Linux

    The ip command has replaced the older ifconfig command in modern versions of Linux. The ip command allows you to configure IP addresses, network interfaces, and routing rules on the fly without rebooting. Run "ip addr" in the Terminal to get your PC's local IP address. You can configure IP addresses, network interfaces, and routing rules on the ...