Alternative to IPConfig on Ubuntu

This guide will show you a couple of alternatives to IPConfig on Ubuntu.

Ubuntu IPConfig Alternatives

IPConfig is a tool you may be familiar with if you have ever used Windows for any length of tool. It is a tool that lets you get information about your network interfaces and the IP addresses assigned to your machine.

While Ubuntu doesn’t have a command called “ipconfig“, it has a variety of alternatives you can use.

Over the following two sections, we will cover two alternatives you can use on Ubuntu. The first method is to use ifconfig. ifconfig is the most similar tool to ipconfig on Ubuntu. However, it doesn’t provide all the information you would expect; for example, it doesn’t tell you the DNS addresses for that network interface.

The other method we will cover is using nmcli to get similar information to what ipconfig provides. This tool is more complicated, but it is still an easy way to get all the information about your IP configuration you may need.

Using ifconfig as an alternative to IPConfig on Ubuntu

This section will show you how ifconfig is one of the closest alternatives to Windows’s IPConfig on Ubuntu.

This tool will provide you with information on all your Ubuntu network interfaces. You can see the IP address assigned to your machine using this information.

However, following these steps, you will be missing some of the information ipconfig provides on Windows such as the DNS servers. If you require this information, you will want to use the nmcli tool instead.

Installing ifconfig on Ubuntu

1. Typically, the ifconfig tool comes pre-installed on Ubuntu, however, that might only sometimes be the case. Don’t worry, as this tool is relatively easy to install.

The first thing you do, before you install this ipconfig alternative to Ubuntu, is to update the package list cache and upgrade any out-of-date packages. You can perform both tasks by running the following two commands in the terminal.

sudo apt update
sudo apt upgrade -y

2. Once Ubuntu has finished updating, you can install the package that contains “ifconfig” on Ubuntu by running the command below.

sudo apt install net-tools

Using ifconfig to Get Details on Ubuntu like IPConfig

3. Getting the ifconfig tool on Ubuntu to output information about your network interfaces and produce a result similar to the IPconfig tool on Windows is simple.

All you need to do to output this information is to run the following command within the terminal.

sudo ifconfig

Alternatively, you can also use the “ip” command to get similar information, especially considering “ifconfig” is an alias of the “ip” command.

ip addr show

4. Below is an example of the kind of information given to you by the ifconfig tool.

With this, you can see each of the IP addresses that have been assigned to your machine as well as other information such as the gateway.

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

enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.9  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXX  prefixlen 64  scopeid 0x0<global>
        ether 52:54:00:87:6c:0b  txqueuelen 1000  (Ethernet)
        RX packets 8901147  bytes 4920002984 (4.9 GB)
        RX errors 0  dropped 36  overruns 0  frame 0
        TX packets 1191077  bytes 208128179 (208.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

How to use nmcli as an Alternative to IPConfig

One downside of using ifconfig on Ubuntu is that it only gives you some of the information the ipconfig tool provides.

Luckily, Ubuntu offers another way of getting similar information, which is by using the nmcli tool. This tool is a command line interface for talking with Network Manager. With this tool, you can easily get all of the IP information about a particular network adapter, including the upstream DNS servers.

All desktop versions of Ubuntu since 16.04 have included Network Manager. Please note that the server version doesn’t use Network Manager, so the following alternative to IPConfig won’t work on Ubuntu server.

1. To use the nmcli tool as an alternative to ipconfig on Ubuntu, you will simply need to use the following command within the terminal.

Be prepared for a data dump, as this command will give you all of the IP configuration settings of your network devices. If you only want IP information, then skip to our next step.

nmcli device show

Below is an example of the data you can get by running this command. While it doesn’t output the same as the ipconfig tool on Windows, it does give you the same data you would expect to get.

GENERAL.DEVICE:                         enp1s0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         52:54:00:87:6C:0B
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     Supervisor enp1s0
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/3
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         192.168.0.9/24
IP4.GATEWAY:                            192.168.0.1
IP4.ROUTE[1]:                           dst = 192.168.0.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[2]:                           dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 1000
IP4.ROUTE[3]:                           dst = 0.0.0.0/0, nh = 192.168.0.1, mt = 100
IP4.DNS[1]:                             192.168.0.1
IP4.DOMAIN[1]:                          localdomain
IP6.GATEWAY:                            XXXX::XXXX:9aff:fe59:6e6
IP6.DNS[1]:                             XXXX::XXXX:9aff:fe59:6e6
IP6.DNS[2]:                             XXXX:XXXX:41c4:7000::1

GENERAL.DEVICE:                         br-336b32863a1a
GENERAL.TYPE:                           bridge
GENERAL.HWADDR:                         02:42:39:CD:C4:57
GENERAL.MTU:                            1500
GENERAL.STATE:                          10 (unmanaged)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
IP4.ADDRESS[1]:                         172.21.0.1/16
IP4.GATEWAY:                            --
IP4.ROUTE[1]:                           dst = 172.21.0.0/16, nh = 0.0.0.0, mt = 0
IP6.ADDRESS[1]:                         XXX::XX:XXXX:XXXX:XXXX/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 256

2. You can narrow this command down to just your IPv4 or IPv6 information by modifying this command slightly. With these changes, we tell the command what network adapter to use to grab the information we are after. We pipe the information from this command straight into “grep,” so we only get the IP data.

Replace “<DEVICENAME>” with the name of the network adapter you want to get the IP configuration of.

nmcli device show <DEVICENAME> | grep "IP"

For example, we would use the following command on Ubuntu if we wanted to get information similar to what IPConfig gives us about our “enp0s1” network adapter.

nmcli device show enp0s1 | grep "IP4"

Below is an example of the data that will be returned after running the command above.

IP4.ADDRESS[1]:                         192.168.0.9/24
IP4.GATEWAY:                            192.168.0.1
IP4.ROUTE[1]:                           dst = 192.168.0.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[2]:                           dst = XXX.XXX.0.0/16, nh = 0.0.0.0, mt = 1000
IP4.ROUTE[3]:                           dst = 0.0.0.0/0, nh = 192.168.0.1, mt = 100
IP4.DNS[1]:                             192.168.0.1
IP4.DOMAIN[1]:                          localdomain
IP6.ADDRESS[1]:                         XXXX:XXXX:XXXX:cd40:ec3b:3291:6486:5315/64
IP6.GATEWAY:                            XXXX::XXXX:XXXX:fe59:6e6
IP6.ROUTE[1]:                           dst = XXXX:XXXX:XXXX:7000::/64, nh = ::, mt = 100
IP6.ROUTE[2]:                           dst = XXXX:XXXX:XXXX:cd40::/64, nh = ::, mt = 100
IP6.DNS[1]:                             XXX::XXXX:9aff:fe59:6e6
IP6.DNS[2]:                             XXX:XXXX:41c4:7000::1

Conclusion

At this point in the guide, you should now hopefully have a good idea of how you can get similar information to IPConfig on Ubuntu

There are two tools in particular that we covered in this guide. The first was ifconfig. The second was nmcli. Both tools can give you results similar to those of IPConfig on Windows.

Please feel free to drop a comment below if you have any questions about using these alternatives to IPConfig on Ubuntu.

If you liked this Ubuntu guide, we highly recommend that you explore our many other Ubuntu tutorials.

Leave a Reply

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