Configure Static IPv4 Address in OpenShift 4.x CoreOS Servers

Posted on 259 views

You just finished setting up your OpenShift 4.x or OKD 4.x cluster and would like to have static IP addresses configured on the nodes?. This is a common requirement for an OpenShift UPI cluster deployed on-premise, e.g cluster installed in a VMware, RHEV or Baremetal servers where DHCP server is not highly reliable. In this post we will use nmcli Network Management tool to configure static IPv4 address on OpenShift 4.x servers – Infra, Masters and Worker machines.

Since the process used in this guide is manual, it means you need ssh access to the servers where static IP address is to be configured. In our example, where DHCP server was used to assign IPv4 address to the machines during bootstrapping, below is sample DHCP configuration for worker machines.

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’ll login to one of the worker nodes – worker1 , whose IP Address assigned though 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 oc debug command to gain shell access to the node.

$ oc debug node/

Configure Static IP Address in Red Hat CoreOS / Fedora CoreOS using NMCLI

Once you’re logged in to the terminal check network configuration with nmcli.

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

You can get more details about the connection:

$ nmcli con show 'Wired connection 1'

To configure IPv4 address, Gateway and DNS update the network connection settings with nmcli.

sudo nmcli connection mod 'Wired connection 1' \
ipv4.method manual \
connection.autoconnect yes \
ipv4.addresses \
ipv4.gateway \
ipv4.dns \

In my setup the settings used are:

  • is the IPv4 address of the server.
  • is the gateway and DNS server IPv4 address.
  • is the secondary DNS server IPv4 address.
  • connection.autoconnect yes‘ sets the connection to come up on system boot.
  • ipv4.method manual‘ switch the connection from DHCP to Static IPv4 address.
  • Wired connection 1‘ is the name of connection to be modified.

Upon execution a static network configuration script is created.

$ ls /etc/sysconfig/network-scripts/

Reboot to confirm if the IP address request is sent to DHCP server or assigned manually.

sudo systemctl reboot

Set Hostname on Red Hat CoreOS / Fedora CoreOS using NMCLI

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

sudo nmcli general hostname

Confirm the setting.

$ 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 cat the /etc/hostname file.

$ cat /etc/hostname

You now have static IPv4 address set in your Red Hat CoreOS and Fedora CoreOS servers. Stay connected for more OpenShift guides while checking other available guides.


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.