The purpose of this tutorial is to show how to find the system IP address, public IP address, default gateway, and DNS servers on CentOS Linux and Red Hat Linux. This can be done from both command line and GUI. We will cover the step by step instructions for both methods below.
On Redhat Linux systems, the
ifconfig
command to display a system IP address has become obsolete. It can only be used on up to date systems if you install the missing ifconfig command.In this tutorial you will learn:
- How to find local and public IP address
- How to check for default gateway
- How to display DNS server IP address
- How to display MAC address

Category | Requirements, Conventions or Software Version Used |
---|---|
System | CentOS Linux or Red Hat Linux |
Software | N/A |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
How to check IP address on CentOS / Red Hat step by step instructions
Find IP address from command line
First we will cover the instructions to get IP address and other network information from command line.
- Get started by opening a command line terminal and check for your internal IP address by executing the
ip
command.$ ip a
Locate the requested network interface and check for assigned IP address. Additionally, the above command also reveals the network interface hardware address a.k.a MAC address.
- There are also various ways to get your public IP address. You can go to a website like ip chicken or execute one of the following commands in terminal:
# echo $(wget -qO - https://api.ipify.org) OR # echo $(curl -s https://api.ipify.org)
- To check for currently used DNS server IP address execute:
$ grep nameserver /etc/resolv.conf
- To display the default gateway IP address run:
$ ip r

Check for internal network configuration from GUI
Assuming that you are using the default GNOME desktop environment, to check for the internal IP address, default gateway, MAC address and DNS server settings on CentOS or Red Hat desktop first open Settings
and click on Network
menu and hit the gear wheel of the desired network interface.

Closing Thoughts
In this tutorial, we saw how to get network information from command line and GUI on CentOS and Red Hat Linux. Such information includes the IP address, MAC address, default gateway, and DNS server IP addresses that are configured for the system.