Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Distributions»CentOS»How to Configure Static IP on CentOS 8 (CLI)

    How to Configure Static IP on CentOS 8 (CLI)

    By RahulOctober 9, 20192 Mins Read

    There are two quick ways to configure an IP address on the network interface of the CentOS 8 operating system. The one is using nmtui command and another is by directly edition networking files.

    Advertisement

    If you are not comfortable to edit configuration files, choose option 1 to set up networking in an interactive way.

    Method 1 – Using nmtui Tool

    Execute the following command to get access to an interactive way of network interface configuration.

    sudo nmtui
    

    Now, edit the default existing connection. In case no connection is available, use Activate a connection.

    Setup networking centos 8

    You will see the list of Ethernet interfaces, Select the interface you want to configure, Then select Edit option on the right side of the interface.

    Configure static IP centOS 8

    Keep the profile name and device name unchanged. Set the IP address, gateway and DNS servers under the IPv4 configuration option. You can add multiple addresses by selection option just below IP address box.

    Use nmtui network configuration on centos 8

    Save the configuration and restart the NetworkManager service using the following command.

    sudo systemctl restart NetworkManager.service
    

    Method 2 – Using Configuration Files

    The default netework interfaces configuration file exists in /etc/sysconfig/network-scripts/ directory. The file name may vary as per your installation type like Physical machine or Virtual machine. The configuration file shoul be like ifcfg-XXXX (eg: ifcfg-eth0, ifcfg-eth1, ifcfg-enp0s3 etc)

    sudo vim /etc/sysconfig/network-scripts/ifcfg-enp0s3
    

    Use the following configuration to configure a static IP address for your CentOS 8 network interface.

    Static IP Configuration:

    TYPE=Ethernet
    BOOTPROTO=static
    NAME=enp0s3
    DEVICE=enp0s3
    ONBOOT=yes
    IPADDR=192.168.1.237
    PREFIX=24
    GATEWAY=192.168.1.2
    DNS1=8.8.8.8
    DNS2=192.168.1.2
    USRCTL=no
    

    Alternatively, if you want to assign IP address via the DHCP server use the following settings.

    DHCP Configuration

    TYPE = Ethernet
    DEVICE = enp0s3
    BOOTPROTO = dhcp
    ONBOOT = yes
    

    Details of configuration parameters:

    • DEVICE: Ethernet device name
    • BOOTPROTO: dhcp or static
    • ONBOOT: yes/no , it tells that interface will automatically up or not on boot.
    • Type: Type of interface.
    • USRCTL: yes/no , it tells that a non root user can bring this device up or down.

    Save the configuration and restart the NetworkManager service using the following command.

    sudo systemctl restart NetworkManager.service
    

    All done.

    CentOS 8 RHEL8
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Installing Security Updates on CentOS 8

    How To Install Security Updates on CentOS 8 (Manual + Automatic)

    How to Install PHP 8 on CentOS/RHEL 8

    How to Install Python 3.9 on CentOS/RHEL 8

    View 1 Comment

    1 Comment

    1. Dan Gordon on July 25, 2020 4:23 pm

      Dear Rahul – I have a cluster with 4 ethernet connections for every node, including the master. But only 2 are used in the master (external and internal eth cables). After setting up the network, everything works fine. But I had to poweroff the cluster for some reason. After turning it on again, everything got waywire: the external eth did not work and neither could the internal connections to the nodes. After every reboot, the up/down status of the connections change. Is there a method to guarantee that connections will endure a reboot or a poweroff?

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Setting Up Angular on Ubuntu: Step-by-Step Guide
    • Converting UTC Date and Time to Local Time in Linux
    • Git Restore: Functionality and Practical Examples
    • Git Switch: Functionality and Practical Examples
    • Git Switch vs. Checkout: A Detailed Comparison with Examples
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.