Configure static IPv4 address in OpenShift 4.x CoreOS server

You can download this article in PDF format via the link below to support us.
Download the guide in PDF formatturn off

You have just finished setting up an OpenShift 4.x or OKD 4.x cluster and want to configure static IP addresses on the nodes? This is a common requirement for OpenShift UPI clusters deployed internally, for example, the cluster is installed in a VMware, RHEV or Baremetal server where the DHCP server is not very reliable.In this article, we will use nmcli Network management tool used to configure static IPv4 addresses on OpenShift 4.x servers (Infra, Masters and Worker computers).

Since the process used in this guide is manual, this means that you need to access the server to be configured with a static IP address via ssh. In our example, a DHCP server is used to assign an IPv4 address to the computer during the boot process. The following is an example of DHCP configuration for a working computer.

subnet netmask {
        pool {
    	    option routers;
            option subnet-mask;
            option broadcast-address;
            option domain-name-servers,;
            option domain-name "";

            # Worker Machines
            host worker1 {
                hardware ethernet 00:50:56:bf:c0:f7;
                option host-name "";
            host worker2 {
                hardware ethernet 00:50:56:bf:07:5a;
                option host-name "";
            host worker3 {
                hardware ethernet 00:50:56:bf:b2:a6;
                option host-name "";

I will log in to one of the worker nodes – Worker 1 , The IP address assigned by the DHCP server is

$ ssh [email protected]
Red Hat Enterprise Linux CoreOS 44.81.202007010318-0
  Part of OpenShift 4.4, RHCOS is a Kubernetes native operating system
  managed by the Machine Config Operator (`clusteroperator/machine-config`).

WARNING: Direct SSH access to machines is not recommended; instead,
make configuration changes via `machineconfig` objects:

Last login: Sat Oct 31 19:55:16 2020 from
[[email protected] ~]$ 

You can also use the oc debug command to get Shell access to the node.

$ oc debug node/<nodename>

Use NMCLI to configure a static IP address in Red Hat CoreOS / Fedora CoreOS

After logging in to the terminal, use nmcli to check the network configuration.

$ nmcli connection show 
NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  1dbbec73-04b1-3726-9d04-458f9ba17ff6  ethernet  ens192 

You can get more detailed information about the connection:

$ nmcli con show 'Wired connection 1'

To configure the IPv4 address, the gateway and DNS use nmcli to update the network connection settings.

sudo nmcli connection mod 'Wired connection 1' 
ipv4.method manual 
connection.autoconnect yes 

In my settings, the settings used are:

  • Is the IPv4 address of the server.
  • Is the IPv4 address of the gateway and DNS server.
  • Is the IPv4 address of the secondary DNS server.
  • connection.autoconnect is‘Set up the connection to start at system startup.
  • ipv4.method manualSwitch the connection from DHCP to static IPv4 address.
  • Wired connection 1‘Is the name of the connection to be modified.

After execution, a static network configuration script will be created.

$ ls /etc/sysconfig/network-scripts/

Restart to confirm whether the IP address request is sent to the DHCP server or assigned manually.

sudo systemctl reboot

Use NMCLI to set hostname on Red Hat CoreOS / Fedora CoreOS

You can also use the NMCLI command line tool to configure the static hostname of the CoreOS server.

sudo nmcli general hostname

Confirm the settings.

$ hostnamectl 
   Static hostname:
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 93ba80b38e9948acbb6aa6346bb5312c
           Boot ID: d885cc0011c04ac08c4d3e3ef3441ed0
    Virtualization: vmware
  Operating System: Red Hat Enterprise Linux CoreOS 44.81.202007010318-0 (Ootpa)
            Kernel: Linux 4.18.0-147.20.1.el8_1.x86_64
      Architecture: x86-64

You can also choose /etc/hostname file.

$ cat /etc/hostname

Now you have set a static IPv4 address in the Red Hat CoreOS and Fedora CoreOS servers. While checking other available guides, keep in touch for more OpenShift guides.

How to list and approve pending CSRs in OpenShift 4.x

Send OpenShift logs and events to Splunk

Grant users access to projects/namespaces in OpenShift

You can download this article in PDF format via the link below to support us.
Download the guide in PDF formatturn off