Most IPs these days are automatically assigned through DHCP by either your ISP or your home router. But there may come a time when you wish to opt for a static IP address and you will want to change it. It may be that you are configuring a home LAN and you don't want to use DHCP or simply want a static IP address that you can access from outside your home. In this tutorial we will learn how we can change the IP address in RedHat Enterprise Linux 8.0.

In this tutorial you will learn:
  • How to change the IP address in RHEL 8 using GNOME
  • How to change the IP address by editing configuration files
  • How to manually change your DNS server
  • How to restart networking in RHEL 8
Changing the IP address in RHEL 8 from within GNOME is a matter of a few clicks
Changing the IP address in RHEL 8 from within GNOME is a matter of a few clicks.

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System RedHat Enterprise Linux 8.0
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

The GUI way

The easiest way to change your IP address in RedHat Enterprise Linux 8 is to use GNOME's Settings window. Go to Settings and the last entry in the left side panel is Network. Click on Network and click the wheel button next to your network card. This will bring up another window with five tabs, one of which is IPv4. Set IPv4 Method to Manual and enter your static IP address, netmask, gateway and DNS server in their respective fields. The exact same procedure is done if you wish to use IPv6. Hit Apply when you are done.


SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


Changing the IP address in RHEL 8 from within GNOME is a matter of a few clicks
Changing the IP address in RHEL 8 from within GNOME is a matter of a few clicks.

The CLI way

You can manually change your IP address by modifying the corresponding configuration file for each network card. First see how your network cards are named by invoking ifconfig in a Terminal window:

$ ifconfig
or
$ ip a

The output for a wired connection should name your network card something like ens33.

With ifconfig you can view your IPv4 and IPv6 address and the name of your network cards
With ifconfig you can view your IPv4 and IPv6 address and the name of your network cards.

To edit the details of this network connection edit the card's configuration file:

# nano /etc/sysconfig/network-scripts/ifcfg-ens33

There are two things you need to do here. Edit the BOOTPROTO entry from



BOOTPROTO=dhcp

to

BOOTPROTO=static

and then add the following lines to the end of the file or right after the BOOTPROTO line:

IPADDR=192.168.1.5
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
Your network card's configuration file should look similar to this
Your network card's configuration file should look similar to this.

Substitute the IPs corresponding to IPADDR, NETMASK and GATEWAY with the ones you desire for your network then save the file with Ctrl+X. Nameservers are located in the /etc/resolv.conf file, so we will edit that too if needed:

# nano /etc/resolv.conf

Change the nameserver line to something like

nameserver 8.8.8.8

which is one of Google's DNS servers. Save the file with Ctrl+X. Now you only have to restart networking to make these changes take effect. You can do this turning it off with

$ nmcli networking off


then back on again with

$ nmcli networking on

Conclusion

Since RHEL 8 the network.service file was changed to the NetworkManager.service system that is designed to always run as a daemon. But changing the IP address in RHEL 8 is basically the same as it was in RHEL 7. If you want to use a static address instead of DHCP you can use the above guide to manually configure each of your network cards.

ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions